From: Grasavong on
Oh - I forgot to mention that each record has a specific ID (it's the primary
key as well). Sort of like, If all the specified fields for ID01 is
populated, please make read-only...something to that affect.

"Grasavong" wrote:

> There are two people contradicting each other.
>
> One person says "A form contains multiple records"
> Another person says "Forms do not contain records"
>
> I would like my question answered, if possible, and it can't, just please
> let me know despite some incorrect terminology. This is what I did,
> step-by-step:
>
> 1) I created a table with multiple fields. Each field is populated with data
> which eventually becomes a record. From that, 2)I created a form where I
> choose which fields to put into my form. From there, 3) users use the form to
> populate their data into the fields, which is stored in the table.
>
> In the end, when ALL the fields in THAT form have been completed, the ones I
> CHOSE to be placed in that form, I want the form to be read-only. Maybe
> read-only is not the correct term, disabled may be the correct term. Either
> way, can I do it this way by using some AfterUpdate even Procedure? If so,
> how? Can only one record be disabled without affecting the other records?
>
> That's the way I'd like the form to work.
> Thank you.
>
> "John W. Vinson" wrote:
>
> > On Tue, 23 Feb 2010 13:41:02 -0800, Grasavong
> > <Grasavong(a)discussions.microsoft.com> wrote:
> >
> > >Basically, I have created a form. There are multiple records in the form that
> > >has to be populated. Once ALL those records have been populated, I want that
> > >record to be read-only.
> >
> > Forms do not contain records.
> >
> > Forms are dynamic windows, NOT data repositories.
> >
> > The records are stored in Tables, and only in Tables.
> >
> > If you could describe your Tables, how (if at all) they are related, and what
> > constitutes "completion" - in terms of fields and records in your tables -
> > someone might be able to help.
> > --
> >
> > John W. Vinson [MVP]
> > .
> >
From: John W. Vinson on
On Wed, 24 Feb 2010 05:55:01 -0800, Grasavong
<Grasavong(a)discussions.microsoft.com> wrote:

>There are two people contradicting each other.
>
>One person says "A form contains multiple records"
>Another person says "Forms do not contain records"

Well, sorry: that was misleading. A form *displays* records but the records
aren't contained in the form, any more than the Owyhee Mountains are contained
in my office window.

>I would like my question answered, if possible, and it can't, just please
>let me know despite some incorrect terminology. This is what I did,
>step-by-step:
>
>1) I created a table with multiple fields. Each field is populated with data
>which eventually becomes a record. From that, 2)I created a form where I
>choose which fields to put into my form. From there, 3) users use the form to
>populate their data into the fields, which is stored in the table.
>
>In the end, when ALL the fields in THAT form have been completed, the ones I
>CHOSE to be placed in that form, I want the form to be read-only. Maybe
>read-only is not the correct term, disabled may be the correct term. Either
>way, can I do it this way by using some AfterUpdate even Procedure? If so,
>how? Can only one record be disabled without affecting the other records?

This can be done, but it's a bit of work. I presume that you want the user to
be able to enter some of the fields, close the form, go off and do something
else, open it up, add a few more fields, go to a different record and add some
fields, etc.... until all 28 fields (or however many) have been filled in? Do
you want the form to instantly lock up at that point, or just when the user
opens the form and navigates to it? The latter is simplest, if not very easy.

Open the form in design view. For each control that you want to count toward
"complete", set its Tag property to 1. Then in the form's Current event put
code like:


Private Sub Form_Current()
Dim ctl As Control
Dim bUnlock As Boolean
bUnlock = False
For Each ctl In Me.Controls
If ctl.Tag = 1 Then
If IsNull(ctl) Then
bUnlock = True
Exit For
End If
End If
Next ctl
Me.AllowUpdates = bUnlock
End Sub

This will loop through all the controls on the form (labels, rectangles,
lines, textboxes, etc.); if the control is a data-containing control with its
tag set, it will check to see if the control is empty; if there is ANY empty
control, the variable bUnlock will be True. If all of the controls have data
it will be False at the end of the loop. The form's Allow Updates property
will then be set to allow updates only if there is still at least one control
empty.

If you want the form to lock up the moment the last textbox is filled in...
well, it will probably be possible but I'd think it's a bad idea, unless you
are absolutely certain that no user will EVER need to correct a mistake.
--

John W. Vinson [MVP]
From: Grasavong on
Thank you for your reply and patience. I agree that locking the form after
each field is completed is not a very good idea, but there is a reason why
they want it done that way. Just as long as the owner of the database can
turn off the lock, they don't care that the user can't go back and edit the
form.
"John W. Vinson" wrote:

> On Wed, 24 Feb 2010 05:55:01 -0800, Grasavong
> <Grasavong(a)discussions.microsoft.com> wrote:
>
> >There are two people contradicting each other.
> >
> >One person says "A form contains multiple records"
> >Another person says "Forms do not contain records"
>
> Well, sorry: that was misleading. A form *displays* records but the records
> aren't contained in the form, any more than the Owyhee Mountains are contained
> in my office window.
>
> >I would like my question answered, if possible, and it can't, just please
> >let me know despite some incorrect terminology. This is what I did,
> >step-by-step:
> >
> >1) I created a table with multiple fields. Each field is populated with data
> >which eventually becomes a record. From that, 2)I created a form where I
> >choose which fields to put into my form. From there, 3) users use the form to
> >populate their data into the fields, which is stored in the table.
> >
> >In the end, when ALL the fields in THAT form have been completed, the ones I
> >CHOSE to be placed in that form, I want the form to be read-only. Maybe
> >read-only is not the correct term, disabled may be the correct term. Either
> >way, can I do it this way by using some AfterUpdate even Procedure? If so,
> >how? Can only one record be disabled without affecting the other records?
>
> This can be done, but it's a bit of work. I presume that you want the user to
> be able to enter some of the fields, close the form, go off and do something
> else, open it up, add a few more fields, go to a different record and add some
> fields, etc.... until all 28 fields (or however many) have been filled in? Do
> you want the form to instantly lock up at that point, or just when the user
> opens the form and navigates to it? The latter is simplest, if not very easy.
>
> Open the form in design view. For each control that you want to count toward
> "complete", set its Tag property to 1. Then in the form's Current event put
> code like:
>
>
> Private Sub Form_Current()
> Dim ctl As Control
> Dim bUnlock As Boolean
> bUnlock = False
> For Each ctl In Me.Controls
> If ctl.Tag = 1 Then
> If IsNull(ctl) Then
> bUnlock = True
> Exit For
> End If
> End If
> Next ctl
> Me.AllowUpdates = bUnlock
> End Sub
>
> This will loop through all the controls on the form (labels, rectangles,
> lines, textboxes, etc.); if the control is a data-containing control with its
> tag set, it will check to see if the control is empty; if there is ANY empty
> control, the variable bUnlock will be True. If all of the controls have data
> it will be False at the end of the loop. The form's Allow Updates property
> will then be set to allow updates only if there is still at least one control
> empty.
>
> If you want the form to lock up the moment the last textbox is filled in...
> well, it will probably be possible but I'd think it's a bad idea, unless you
> are absolutely certain that no user will EVER need to correct a mistake.
> --
>
> John W. Vinson [MVP]
> .
>
From: John W. Vinson on
On Wed, 24 Feb 2010 12:01:02 -0800, Grasavong
<Grasavong(a)discussions.microsoft.com> wrote:

>Thank you for your reply and patience. I agree that locking the form after
>each field is completed is not a very good idea, but there is a reason why
>they want it done that way. Just as long as the owner of the database can
>turn off the lock, they don't care that the user can't go back and edit the
>form.

Ok, sorry... but you completely lost me there.

Under what circumstances to you want *an individual textbox* on the form to be
locked?

- After it has been updated, as soon as the user goes to another control on
the form?

or

- After the record has been "completed"?

If the latter, at what point in the process is the record considered complete?
When the user saves it to disk by moving to another record? when every textbox
on the form has been "touched"? or what?

Clearly you could have a second form without this locking behavior, perhaps in
a different frontend, so authorized users could bypass the locking; but -
unless the data is in SQL/Server or another backend with better security than
Access can offer - you won't be able to absolutely prevent a determined and
inquisitive user from bypassing the security.

--

John W. Vinson [MVP]
From: Grasavong on
The latter. When the 'record' has been completed..i.e. every field (or is it
textbox) in that record has data and eventually moves on to another record.
This is an internal database. There are going to be about 10 people that will
use it. Believe me, no one is going to bother to take the time to bypass any
type of security that is put on it.

It's basically Access for dummies. I created the database table, designed
the form, now I want the completed record to be a read-only document
regardless if the user needs to go back and edit it. I know, it doesn't make
sense and I personally don't agree with the idea myself but there's a reason
why they want it this way (if possible).

Thank you.

"John W. Vinson" wrote:

> On Wed, 24 Feb 2010 12:01:02 -0800, Grasavong
> <Grasavong(a)discussions.microsoft.com> wrote:
>
> >Thank you for your reply and patience. I agree that locking the form after
> >each field is completed is not a very good idea, but there is a reason why
> >they want it done that way. Just as long as the owner of the database can
> >turn off the lock, they don't care that the user can't go back and edit the
> >form.
>
> Ok, sorry... but you completely lost me there.
>
> Under what circumstances to you want *an individual textbox* on the form to be
> locked?
>
> - After it has been updated, as soon as the user goes to another control on
> the form?
>
> or
>
> - After the record has been "completed"?
>
> If the latter, at what point in the process is the record considered complete?
> When the user saves it to disk by moving to another record? when every textbox
> on the form has been "touched"? or what?
>
> Clearly you could have a second form without this locking behavior, perhaps in
> a different frontend, so authorized users could bypass the locking; but -
> unless the data is in SQL/Server or another backend with better security than
> Access can offer - you won't be able to absolutely prevent a determined and
> inquisitive user from bypassing the security.
>
> --
>
> John W. Vinson [MVP]
> .
>