"GLT" wrote in message
news
Hi,
I am trying to (using VBA), open a form, populate a combo box, and then
clicka button on the newly opened form...
I have tried the following:
DoCmd.OpenForm "frm01_Services"
Forms.frm01_Services.cmbServer.Value = Me!Server
Forms.frm01_Services.cmdGetServicesData.SetFocus
Forms!frm01_Services.cmbserver_Click -----Error
Line # 3 bombs - is there a function in access that allows me to do this?
You have to modify the definition of the event procedure, in the module of
the form containing it, to make the procedure Public instead of Private. I
think in this line:
Forms!frm01_Services.cmbserver_Click -----Error
.... you probably meant "cmdGetServicesData_Click", since that looks
"cmdGetServicesData" should be the name of your command button. But it
still won't work unless you modify the declaration to be like this:
Public Sub cmdGetServicesData_Click()
Then you should be able to call it like this:
Forms!frm01_Services.cmdGetServicesData_Click
You don't even have to SetFocus to the button, since you are calling the
procedure directly.
--
Dirk Goldgar, MS Access MVP
Access tips:
www.datagnostics.com/tips.html
(please reply to the newsgroup)