unhide database window using VBA...

G

Guest

I have an autoexec macro that fires and hides the database window when the
mdb opens...
My client wants to have a button that closes a form and returns them to the
database window, with the Tables tab selected - but I'm having trouble
accoumplishing this. Here's what I have so far:

1 Private Sub btn_ExitFormOpenDbWindow_Click()
2 DoCmd.Close 'Close the open form
3 DoCmd.RunCommand acCmdWindowUnhide 'unhide cmd window...
4 DoCmd.SelectObject acTable, , True 'select
5 DoCmd.Maximize
6 End Sub

The problem is that the code on line 3 pops up a dialog asking which window
I want to unhide - I want this to be done automatically... any idea how todo
this.

Any thought would be appreciated...

-CEL
 
G

Guest

Try:

Private Sub btn_ExitFormOpenDbWindow_Click()

On Error GoTo ErrHandler

DoCmd.SelectObject acTable, , True
DoCmd.Close acForm, Me.Name
DoCmd.Maximize

Exit Sub

ErrHandler:

MsgBox "Error in btn_ExitFormOpenDbWindow_Click( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear

End Sub ' btn_ExitFormOpenDbWindow_Click( )

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top