How can go to another form, click a button from that form, and then select option button all using vba?
How can go to another form, click a button from that form, and then select option button all using vba?
You might try this link
http://www.techrepublic.com/download...ith-vba/172319
or http://www.accessmvp.com/strive4peace/
What I'm trying to do is click a button. For an example, i open a form, enter a beg. and ending date. When I click the OK button, I want the code to go and click the Report button and select an option button that is below the Report button.
I tried the following:
Form1.setfocus
[forms]![form1].[ReportBtn].setfocus
'need to select the option button
Private Sub StartGather_Click()
On Error Goto Err_StartGather_Click
Dim stDocName as String
Form1.setfocus
[forms]![form1].[ReportBtn].setfocus
DoCmd.GoToControl "Option103"
[Forms]![Form1]![Text77].value = #4/20/2011#
Sendkey Enterkey, True
DoCmd.Hourglass True
stDocName = "GatherData2.start"
DoCmd.RunMacro stDocName
' This will run for up to 1 hour
DoCmd.Hourglass False
Exit_StartGather_Click:
Exit Sub
Err_StartGather_Click:
MsgBox Err.Description
DoCmd.Hourglass False
Resume Exit_StartGather_Click
End Sub
hey bud, you CANNOT 'click' a button in access via code. However, you CAN run procedures behind buttons by simply calling them using the CALL statement. you can call subs and functions both.
access is not like the DOM, where you can use ".click" to manipulate objects on a web page.
Thanks, I didn't you could. I've never done it before. I started going in another direction per this project.
I was able to get the focus to the button, but could not do a Sendkeys EnterKey to click the button.
If, what you want to accomplish is to Open a Report with some parameters, you may find this tutorial "Dynamic Reports" helpful. You create a dialog type form and thenhave code to open a Report.
http://www.fontstuff.com/access/acctut19.htm