checkbox control of txtboxes need a requery?

  • Thread starter Thread starter perryclisbee via AccessMonster.com
  • Start date Start date
P

perryclisbee via AccessMonster.com

Hi,

I have a checkbox [NeedReview] that, when not checked, disables several
textboxes on the form for a given contract. Here's the problem: I uncheck
the checkbox, which disables the associated txtboxes. I check on a different
contract, then come back. The checkbox is still unchecked (which is good)
but the associated txtboxes are re-enabled. Do I need to do some sort of
requery in one of the form events or something? On opening that record, I
want the txtboxes to reflect what the checkbox states.. Any ideas what's
wrong?

**Below is the code which currently controls my enabling efforts:


Private Sub NeedReview_AfterUpdate()

Me!Initial_Sent_Dir.Enabled = (Me!NeedReview = True)
Me!Initial_Returned_Dir.Enabled = (Me!NeedReview = True)
Me!Final_Sent.Enabled = (Me!NeedReview = True)
Me!BillColl_Final_Returned.Enabled = (Me!NeedReview = True)
Me!Legal_Final_Returned.Enabled = (Me!NeedReview = True)
Me!Lab_Final_Returned.Enabled = (Me!NeedReview = True)
Me!cmdDir_Ini_Sent.Enabled = (Me!NeedReview = True)
Me!cmdDir_Ini_Ret.Enabled = (Me!NeedReview = True)
Me!cmdFinalStart.Enabled = (Me!NeedReview = True)
Me!cmdPCFinalNow.Enabled = (Me!NeedReview = True)
Me!cmdLegalFinalNow.Enabled = (Me!NeedReview = True)
Me!cmdLabFinalNow.Enabled = (Me!NeedReview = True)

End Sub


Thanks,

Perry
 
First, you can simplify your coding:

If Me.NeedReview = True Then
Me.Initial_Sent_Dir.Enabled = True
Me.Initial_Returned_Dir.Enabled = True
etc.
End If

There are some other things you could do, such as setting the Tag property
of a control (to 999, in this case) and looping through the controls, but I
can't be sure offhand of how to go about that. I think it goes like this:

Dim ctl As Control

If Me.Check1 = True Then
For Each ctl In Me.Controls
If ctl.Tag = 999 Then
ctl.Enabled = False
End If
Next ctl
End If

In any case, you need to run the code in the form's Current event. One way
to do this is to make the code a Public sub in the form's Declarations
section, then call the sub from the check box After Update event and the
form's Current event. If you named the sub ReviewNeeded you would just
place:
Call ReviewNeeded
in the appropriate event.
 
Looks like using the call worked great!
Thanks for the help.
First, you can simplify your coding:

If Me.NeedReview = True Then
Me.Initial_Sent_Dir.Enabled = True
Me.Initial_Returned_Dir.Enabled = True
etc.
End If

There are some other things you could do, such as setting the Tag property
of a control (to 999, in this case) and looping through the controls, but I
can't be sure offhand of how to go about that. I think it goes like this:

Dim ctl As Control

If Me.Check1 = True Then
For Each ctl In Me.Controls
If ctl.Tag = 999 Then
ctl.Enabled = False
End If
Next ctl
End If

In any case, you need to run the code in the form's Current event. One way
to do this is to make the code a Public sub in the form's Declarations
section, then call the sub from the check box After Update event and the
form's Current event. If you named the sub ReviewNeeded you would just
place:
Call ReviewNeeded
in the appropriate event.
[quoted text clipped - 31 lines]
 
Back
Top