disable/enable button

deepbreath

Registered User.
Local time
Today, 16:59
Joined
Apr 18, 2001
Messages
73
i have a button on my form which opens another form and takes you to a particluar record, depending on criteria. can i diable it if certain value in a textbox is null. in not null then it should be enabled.
 
I believe I have what you want:
The following code will disable your button if the value in a textbox is Null. Put the code in the On_current event of your form, and in the after_update event of the textbox the value will be in.
That way if the user then enters a value the control button will enable.

First, in the Tag property of the control button put disable

Here is the code:

Dim frmMyForm As Form
Dim ctlMyCtls As Control
Set frmMyForm = Forms!nameofyourform

If IsNull(nameoftxtbox.value) Then
For Each ctlMyCtls In frmMyForm.Controls
If ctlMyCtls.Tag = "disable" Then
ctlMyCtls.Visible = True
ctlMyCtls.Enabled = False
Me.refresh
End If
Next ctlMyCtls
Else
For Each ctlMyCtls In frmMyForm.Controls
If ctlMyCtls.Tag = "disable" Then
ctlMyCtls.Visible = True
ctlMyCtls.Enabled = True
Me.refresh
End If
Next ctlMyCtls
End If

HTH
 
You could use the On Current event of your form to check the value in the txtbox then enable/disable the button as needed.

Private Sub Form_Current()
If IsNull(Me.YourTxtBoxName) Then
  Me.YourButtonName.Enabled = False
Else
  Me.YourButtonName.Enabled = True
End If
End Sub

HTH
RDH

[This message has been edited by R. Hicks (edited 08-01-2001).]
 

Users who are viewing this thread

Back
Top Bottom