'firing' a Button!

S

Soddy

Hello!

I use to know how to do this, but I have forgotten!! I have an event
procedure on a form for a textbox (txtBox_GetFocus). When this control 'gets
the focus' (in the txtBox_GetFocus event), I want it to 'fire' a Button
(cmdButtonOne) on the same form to to something. Something similar to this:

Sub txtBox_GetFocus()
Me![cmdButtonOne].Click ! Of course, this doesn't work - need HELP!
End Sub
 
K

Ken Sheridan

Soddy said:
Hello!

I use to know how to do this, but I have forgotten!! I have an event
procedure on a form for a textbox (txtBox_GetFocus). When this control 'gets
the focus' (in the txtBox_GetFocus event), I want it to 'fire' a Button
(cmdButtonOne) on the same form to to something. Something similar to this:

Sub txtBox_GetFocus()
Me![cmdButtonOne].Click ! Of course, this doesn't work - need HELP!
End Sub
 
J

Jeff Boyce

Soddy

Try something like:

Call cmdButtonOne_Click()

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
K

Ken Sheridan

Assuming the button's On Click event property is an event procedure call the
procedure:

Sub txtBox_GetFocus()

cmdButtonOne_Click

End Sub

If it’s a macro then you'd run the macro with the RunMacro method of the
DoCmd object:

DoCmd.RunMacro "YourMacro"

If it’s a function you'd call the function:

Dim retVal

retVal= YourFunction()

Ken Sheridan
Stafford, England
 
Top