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!

Autoforms in VBA

Status
Not open for further replies.

lth

Programmer
Nov 29, 2002
10
0
0
GB
Is there any way to use Access's handy autoform creator using either VBA or macros? Because it would be really handy.

Thanks

Kendrick
 
DoCmd.RunCommand acCmdNewObjectAutoForm but I'm not sure beyond that. Any? command that can be done via the menu system can be replicated with acCmd etc, just query the object browser with F2 to see them.

Hope this helps and Good LucK!
 
Thanks, I'll give it a go.
 
OK, with a bit of poking around, I now have the following code scrap:

docmd.selectobject acQuery, <query name>, true
docmd.runcommand accmdnewobjectautoform

...which does what I want. Yay! But, can I get another database (ie not the current open one) to create the form?

I guess I'm asking if you can do <otherdatabase>.docmd <whatever>

Thanks a lot for your help already!

Kendrick
 
I don't know, try it and see. The following will get you a differeent database for testing purposes:

Dim objAccess As Object
Set objAccess = GetObject(DatabaseNameWithPath)
objAccess.DoCmd. etc

Please repost and let me know if this works. It could come in handy somewhere down the road.

Good Luck!
 
Well, I hacked together a solution for myself by poking around on MSDN:

Dim RemoteApp As Access.Application
Set RemoteApp = CreateObject(&quot;Access.Application&quot;)
RemoteApp.OpenCurrentDatabase <filename>
RemoteApp.DoCmd.<whatever>

RemoteApp.CloseCurrentDatabase

I'm not sure whether you can still do docmds in your original database whilst you are using remoteapp (I guess so though).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top