Make a form field invisible

A

AJ

I have 4 input fields on a form and if a user starts typing in one, I would
like 2 other ones to become invisible or not allow the user to input into
them.
Example.
employeeNum field
department_id
or
ss_num
birthdate

I only want them to populate either the first two or last two and would like
to eliminate the chance that they can populate both sets.

Is this possible? Thanks.
 
A

Al Campagna

AJ,
It would be better to use each field's AfterUpdate event, rather than
when typing begins.
Let's say the user enters a value in the EmpNo...

Private Sub EmpNo_AfterUpdate
If Not IsNull(EmpNo) Then
SSNum.Visible = False
BirthDate.Visible = False
Else
SSNum.Visible = True
BirthDate.Visible = True
End If
End Sub

This would also handle the case where the user deletes the EmpNo entry.

Use the same logic for your other three fields.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
A

Arvin Meyer [MVP]

You can lock, disable, or hide any control that does not have the focus.

Me.employeeNum.Visible = False
Me.employeeNum.Locked = True
Me.employeeNum.Enabled = False
 

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