Click a button on a form in a remote db

DataMiner

Registered User.
Local time
Today, 17:05
Joined
Jul 26, 2001
Messages
336
I would like to be able to manipulate a form in a remote database. I want to set a bunch of controls on the form to the correct paramaters and then click a button on the form which runs a report. HEre's what I have so far. Everything works except for the !stdgo_click, which is intended to trigger the code in the on-click event of the stdgo command button.

Function PrintReports()
Dim DB As DAO.Database, appAccess As Access.Application

Set appAccess = CreateObject("Access.Application")
' Open database in Microsoft Access window.
appAccess.OpenCurrentDatabase pcainternal_fe
With appAccess.Forms("PCAINternalswitchboard")
!selectclear.Value = 2
!smtpareto.Value = True
!stdHardCopy.Value = False
!dailyweekly.Value = 1
!HardCopy = !stdHardCopy
!Noun.Enabled = False
!PartNumberToggle = 0
!PartNumber.Enabled = False
!RefDesToggle = 0
!RefDes.Enabled = False
!RepCodeToggle = 0
!RepCode.Enabled = False
!InspectPoint.Enabled = False
!InspChoice.Value = 1
!RespChoice.Value = 3
!Value.Enabled = True
!DivisionToggle = 0
!Division.Enabled = False
!stdgo_click
End With

End Function

I am thinking this has something to do with the public/private settings a references. How do I make this work?

Using Access 2002
 
Does it work if you define the Click event of that command button as Public rather than Private? It would then become a method of the form. I would *not* use a bang "!" to reference it. Use a period ".stdgo_click".
 
Instead of using the on click event of a button, create a Function in a public module and then set the button to run that and you should be able to call the function when you are connected up. In other words, the button click will run the function and you can also run the function without clicking the button.
 
Setting the stdgo_click event to public works great. Thanks! I think the separate function thing would work, too, but just setting the click event to public seems easier.

BTW, my work-around, which also seems to work, is to set the focus to the stdgo button and then use sendkeys "{ENTER}"
 
SendKeys is *not* reliable and Bob's solution is better than mine.
 
just an fyi for you too - by making a private event on a form public, you will not be able to use the same name for any button in your database. So, if you had a button named cmdPrint and you make it's click event public then you can't use the name cmdPrint on any other form (when it's Private you can).
 
G’day Bob.

I do not understand your last post (post #6 in this thread) and was wondering if you might like to expand on it please.

Regards,
Chris.
 
If you have a button named cmdPrint, and you change Private cmdPrint_Click() to
Public cmdPrint_Click()
then you cannot have a button named cmdPrint on any other form. Normally you could have a button on several forms, named the same with the same code (so easily copied and pasted for reuse on each form).
 
You get up early, don't you Bob?
Yes, I have to catch a bus for work at 5:45am, so I am up by 4:30am and I typically check to see if I have posts to respond to and try to quickly respond if I do, prior to leaving for work.
 
I guess I must be doing something wrong but it works ok for me.

I built a form in A97 with a command button called cmdPrint and made its click event handler public. Made a copy of the form and both worked ok. Converted it to A2K and it still worked. Took it to work and converted it to A2K3 and it still works. :confused:
 

Users who are viewing this thread

Back
Top Bottom