Make fields stay invisible.

margt_a

Registered User.
Local time
Today, 03:53
Joined
Aug 15, 2002
Messages
35
Hello. I have a form I use to track survey responses. I have certain questions disappear when certain departments are checked, using the following code on the afterupdate event of the department list box:

Private Sub Department_AfterUpdate()
Select Case Me.Department

Case "Construction Services"
Me.Cextent.Visible = False
Me.Sresponse.Visible = False
Me.Efield.Visible = True

Case "Environmental"
Me.Cextent.Visible = True
Me.Sresponse.Visible = True
Me.Efield.Visible = False

Case "Geotechnical"
Me.Cextent.Visible = True
Me.Sresponse.Visible = True
Me.Efield.Visible = False

End Select
End Sub

It works fine when the survey is first entered. But when I go back to the record, all the fields are visible. How can I have those fields stay invisible on reloading the form? I tried pasting the code above into the OnCurrent or OnLoad events of the form itself, and got nowhere.

Margaret
 
Move the code to the Form OnCurrent event, in the after update event of Department put Form_Current
ie
Private Sub Department_AfterUpdate()
Form_Current
End Sub
 
Problem Solved! (I think.)

No, that didn't work for some reason. Thanks for your help, tho.

What did work was a refresh button from the command button wizard. I pasted the code from the list box before the refresh DoCmd. It made all the necessary fields disappear automatically when I click on it.

Why does it work when I run the code from a command button, and not appended to a combo box, or on the OnCurrent event of the form? How can I make it work automatically?

Margaret
 

Users who are viewing this thread

Back
Top Bottom