B
BruceM
I have a purchase order incorporated into a vendor database. It's a typical
configuration, with a PO table and a related Details table, with a form and
subform used for entering information. This is on one tab of a form with a
tab control. The other tab is for approvals (Financial, etc.). The way it
needs to work is that as soon as an approval has been entered (the Approval
field is no longer null), the PO information is locked to prevent changes.
The approval is entered by a user clicking a command button that inserts
CurrentUser() into the Approval field.
I can set the Tab property of controls that need to be locked to, say, 99,
then use something like the following to accomplish what I need:
If Not IsNull(Me.txtFinanceApproval) And Not
IsNull(Me.txtProductionApproval) Then
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = 99 Then
ctl.Locked = True
End If
Next ctl
End If
Controls associated with approvals (i.e. the text boxes into which
CurrentUser() is inserted) do not have 99 as the Tag property. This allows
approvals to be completed after the rest of the PO is locked. Once all
approvals have been completed I will set Allow Edits and Allow Deletions to
No.
The form's Current event is one place for all of this to occur (either the
partial lockdown of controls with the tag 99 or preventing any edits or
deletions at all). The code to lock controls could be a public sub so that
it can also be run from the command button that inserts CurrentUser as
described above, if needed.
However, I don't know if the form's Current event is the best way to handle
this. Before committing to this route I would like to hear what others have
to say about whether there is a better or more efficient way. I feel like
I'm overlooking something.
configuration, with a PO table and a related Details table, with a form and
subform used for entering information. This is on one tab of a form with a
tab control. The other tab is for approvals (Financial, etc.). The way it
needs to work is that as soon as an approval has been entered (the Approval
field is no longer null), the PO information is locked to prevent changes.
The approval is entered by a user clicking a command button that inserts
CurrentUser() into the Approval field.
I can set the Tab property of controls that need to be locked to, say, 99,
then use something like the following to accomplish what I need:
If Not IsNull(Me.txtFinanceApproval) And Not
IsNull(Me.txtProductionApproval) Then
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = 99 Then
ctl.Locked = True
End If
Next ctl
End If
Controls associated with approvals (i.e. the text boxes into which
CurrentUser() is inserted) do not have 99 as the Tag property. This allows
approvals to be completed after the rest of the PO is locked. Once all
approvals have been completed I will set Allow Edits and Allow Deletions to
No.
The form's Current event is one place for all of this to occur (either the
partial lockdown of controls with the tag 99 or preventing any edits or
deletions at all). The code to lock controls could be a public sub so that
it can also be run from the command button that inserts CurrentUser as
described above, if needed.
However, I don't know if the form's Current event is the best way to handle
this. Before committing to this route I would like to hear what others have
to say about whether there is a better or more efficient way. I feel like
I'm overlooking something.