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.