Hide All Form Fields Until Text Box Is Filled In

seantnash

New member
Local time
Today, 10:08
Joined
Aug 21, 2016
Messages
9
On my form I would like to have all but 1 field ("MembershipNo") hidden until the MemberNo is entered. One of the other fields is called FirstName.

I have tried the following code:

Code:
Private Sub MembershipNo_AfterUpdate()

If MembershipNo = "" Then
Me.FirstName.Visible = False
Else Me.FirstName.Visible = True

End If

End Sub
But the FirstName box is still visible when I load up a blank form.

I know it's going to be something really simple I'm doing / not doing wrong but I'm not sure what.
 
Last edited:
You would need to set the field to not visible in design view as it's default.

You would possibly be better setting the background colour of other controls to indicate they are locked rather than hiding them. No controls visible might mean someone thinks there is something wrong with the form.

If you have many controls on the form, I would use a loop and the controls tag property to set them all in one go after update.
 
The reason it does not work for a new form is that you code is in a control afterupdate event - it is not triggered until that control has been updated.

As minty suggests, make all controls visible property false in design view.

You can also try calling the MembershipNo_AfterUpdate event from the form open, load or current event
 
My gut instinct told me it was that - I just wasn't sure how to correct the problem :)

Thanks very much!
 

Users who are viewing this thread

Back
Top Bottom