Writing code to turn off a command button.

R

Raymond Woytowich

I have been given the task of updating an employee list/personnal
information for a Regional Health Authority.

Because there are 25 facilities in the RHA, lots of employees work in more
the one site. But I only need to have them listed once.

What I have done is I have form (FRM-CheckName)to enter the employee's name.
When I click on the 'check name' button, Access will see if the name has
been entered, then go to a new form.
The new form (FRM-CheckBack)has two command buttons. Once that will add the
name (Add Employee Name)to the table (TBL-EENames) if it is a new name.
Then second (Employee Name Exists) that will close FRM-CheckName without
saving the name.
Is there any way to write VBA code so if the name is already listed that the
(Add Employee Name) button is inactive?

url:http://www.ureader.com/gp/1060-1.aspx
 
K

Ken Snell \(MVP\)

Some generic code that you can modify and then run in the new form's Current
event:

Private Sub Form_Current()
Me.CommandButtonAddName.Enabled = _
DLookup("*","TableWithEmployeeNames", ("FieldWithEmployeeName='" _
& Me.NameOfTextboxWithName.Value & "'") = 0)
End Sub
 

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