Enabling/Disabling Textboxes

  • Thread starter pushrodengine via AccessMonster.com
  • Start date
P

pushrodengine via AccessMonster.com

I’m using the code below to enable “StartPatient†and “EndPatient†textboxes
when “Yes†is entered into the “MultiplePatient†textbox.

Private Sub MultiplePatient_AfterUpdate()

Me.StartPatient.Enabled = (Me.MultiplePatient.Value = "Yes")
Me.EndPatient.Enabled = (Me.MultiplePatient.Value = "Yes")

End Sub


The problem I’m having is when I enter “Yes†or “No†the code behaves perfect,
but if I take the focus away from “MultiplePatient†textbox then come back to
it and remove the entry. As soon as I take the focus away I get a message
“Run-time Error ‘94’: Invalid use of Null.

How do I fix this?

Thanks
 
B

Beetle

Private Sub MultiplePatient_AfterUpdate()

If IsNull (Me.MultiplePatient) Then

Me.StartPatient.Enabled = False
Me.EndPatient.Enabled = False

Else

Me.StartPatient.Enabled = (Me.MultiplePatient.Value = "Yes")
Me.EndPatient.Enabled = (Me.MultiplePatient.Value = "Yes")

End If
End Sub

HTH
 
J

Jeanette Cunningham

Hi,
try something like this:

Private Sub MultiplePatient_AfterUpdate()
If Not IsNull(Me.MultiplePatient) then
Me.StartPatient.Enabled = True
Me.EndPatient.Enabled = True
Else
Me.StartPatient.Enabled = False
Me.StartPatient.Enabled = False
End if
End Sub

Set the 2 text boxes for Start and End patient to enabled = No on their
property sheets

You will probably need to put the code:
If Not IsNull(Me.MultiplePatient) then
Me.StartPatient.Enabled = True
Me.EndPatient.Enabled = True
Else
Me.StartPatient.Enabled = False
Me.StartPatient.Enabled = False
End if


in the Current event of the form as well.

Jeanette Cunningham
 

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