making field unlocked and visible

J

jamccarley

I am trying to set up my form to where if one field is filled in, two other
fields pop up to be filled in. Other wise they are locked and not visible. It
is not working, I thought this would work. The main field is Combo493 (I
probably should have been more descriptive on the name). The two fields I am
trying to control with [Combo493] are "Date_Entered_Into_Glovia" and
"Initial_Move_Ticket_#" (I know that my names are to long and should not
contain spaces or symbols, but I did this when I first was learning access
and now know better.) Here is the code I have

Private Sub Combo493_Afterupdate()


Me.Date_Entered_Into_Glovia.Enabled = False
Me.Initial_Move_Ticket__.Enabled = False

Me.Date_Entered_Into_Glovia.Visible = False
Me.Initial_Move_Ticket___Label.Visible = False

Select Case Me.Combo493.Value

'if selection is not null...
Case Is = Not Null
Me.Date_Entered_Into_Glovia.Enabled = True
Me.Initial_Move_Ticket__.Enabled = True
Me.Date_Entered_Into_Glovia_Label.Visible = True
Me.Initial_Move_Ticket___Label.Visible = True

'End Select

End Sub


Thanks
Josh McCarley
 
G

Graham R Seach

Josh,

The thing to do is create a procedure to handle all this kind of stuff.

Private Function EnableControls()
Me!Date_Entered_Into_Glovia.visible = (Len(Me!Combo493 & "") >0)
Me!Initial_Move_Ticket_#.Visible = (Len(Me!Combo493 & "") >0)
End Sub

Then call this function from the form's Current event:
Call EnableControls

Also call this function from the Exit events of the other two controls. You
can do this in one of two ways.
Firstly, you can simply call the function in the Exit event:
Call EnableControls
Or, secondly, you can enter the function name into the Exit property for
the two controls:
=EnableControls()

I use this construct to handle all my form control enables, setting
visibility, enabled state, colour, and so on.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top