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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close / Hide VBA Editor

Status
Not open for further replies.

lameid

Programmer
Jan 31, 2001
4,212
US
I am programmatically creating a form based on a table. The prolem I have is that after creating an event and closing and saving the form and related module, the VBA editor (VBA IDE) is left open.

An Excerpt of my code...

Code:
    Set mdl = Forms(strDoc).Module
    lngMdlLines = mdl.CreateEventProc("Click", ctl.Name)
    mdl.InsertLines lngMdlLines + 1, vbTab & "RunProcessChain Forms![frm Process]!Process_Id"
    DoCmd.Close acForm, strDoc, acSaveYes
    DoCmd.Close acModule, mdl.Name, acSaveYes

ctl is a control object in case it is not intuitive.

I think I'm just missing knowing what the object is for the editor is?

I'll dig some more...

TIA.
 
Now I Just feel silly, VBE object hanging off the application object... It is at least posible to hide the window.

Code:
Set mdl = Forms(strDoc).Module    
lngMdlLines = mdl.CreateEventProc("Click", ctl.Name)
mdl.InsertLines lngMdlLines + 1, vbTab & "RunProcessChain Forms![frm Process]!Process_Id"
DoCmd.Close acForm, strDoc, acSaveYes
DoCmd.Close acModule, mdl.Name, acSaveYes
[Red]Application.VBE.ActiveWindow.Visible = False[/Red]

I didn't fully test but the module window seemed to keep popping up after each line of code which is why it is last rather than first. Also despite adding docmd.echo False and docmd.echo True, the module window still opens visible. Although wrapping with those commands the visible =False was no longer last and in the same position... Not sure if it is specific commands or behavior of echo method that yields the result. Anyway I think it is as good as it gets. Too bad I can't kill the module screen flashing up to add code.

Also peculiar in my testing was I couldn't figure out how to have the VBE have focus and not Access so that I could close it with sendkeys....
[ponder]
Code:
'Go Figure this closes the entire Access session
Application.VBE.Mainwindow.Setfocus
Sendkeys "%{F4}" 'Alt + F4 to close active window

For those interested this was Access 2003 SP3.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top