Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open access form from vbscript 2

Status
Not open for further replies.

KM8888

Programmer
Nov 21, 2011
69
US
Hi everyone,

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?

Many thanks!
 
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.

Check out my scripting solutions at
Work SMARTER not HARDER.
 
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?

ThankS!
 
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

combo
 
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!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top