I've managed to run the access application I want from vbscript but am having a little trouble with the next steps. I'd like to close a form (if it's open) and re-open it from an external vbscript. Is this possible?
Yes, you can grab the application using the context
Code:
Set Access = GetObject(,"access.application")
Access.Close
You could also automate the keyboard commands to perform the same action using SendKeys. If you go that route be sure to set the focus to your window using appactivate.
I hope that helps.
Regards,
Mark
No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.
Thanks Mark, the .Close prompted an error for me but .Quit seemed to work. I'm just having trouble with the form commands, meaning getting a specific form to open and close. Mainly trying Access.OpenForm "Formname" and DoCmd.OpenForm. Any thoughts on that bit?
You need to refer to the access application object, so [tt]Access.DoCmd.OpenForm "Formname"[/tt]. Use vba in access and its object browser to explore access object model. Most vba code should work except of named constants. You may need [tt]Access.OpenCurrentDatabase[/tt] to open database first
Thanks combo, I tooled around and am just doing a Access.run "procedure" and putting the openform inside the Access procedure, seems to work but I'll be finding a use for your suggestion later on as well. Thanks!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.