View Full Version : disable button till field filled in


JonatABS
12-17-2002, 01:45 PM
I asked this question on another forum that I didnt like.

I asked how I can disable a button till a certain field is filled in.

I got this response

Select the button u want disbled, right mouse click and find enabled on the properties . Set this to no
Now select the fieled u to be filled to make it active , right mouse click and go to properties. Select afterupdate and click on the three dots next to it. Now click code builder, u will open the vb window. now write the code



If Me![your trigger field ] = "" Then
Me![name of button disabled].Enabled = False
Else

Me![name of button disabled].Enabled = True
End If

problem solved



It works however when I go to a new record the button is still enabled.

What can I do to resolve this

Peter D
12-17-2002, 01:54 PM
It sounds like you will need to run the code from two places - the AfterUpdate event of your field, and the OnCurrent event of the form.

The most efficient way to do this is to create a function or sub that contains the "if" statement code and call the function from the AfterUpdate, and OnCurrent event procedures.

Ex of function

Private sub MySub(frm as form)
If frm![your trigger field ] = "" Then
frm![name of button disabled].Enabled = False
Else

frm![name of button disabled].Enabled = True
End If
end sub

Then call it like so:

MySub Me


Hope this helps,