Code doesn't work without MsgBox

dionwr

New member
Local time
Today, 10:37
Joined
Dec 1, 2019
Messages
4
I have some code in a module that will not work UNLESS I put in a MsgBox just before the code that's running.

This is the code:

Private Sub Form_Open(Cancel As Integer)
SendKeys "{F11}"
MsgBox "Welcome to the Request Tracker", , "Request Tracker"
'select the navigation pane
Call DoCmd.NavigateTo("acNavigationCategoryObjectType")
'hide the selected object
Call DoCmd.RunCommand(acCmdWindowHide)
'hide the tool ribbon
DoCmd.ShowToolbar "Ribbon", acToolbarNo
End Sub[/FONT]

I'm trying to close the navigation pane and the toolbar, and the code works--but only if that MsgBox is there before it.

Does anyone have any idea why this might be?

Thanks,
Hank
 
Hi. Welcome to AWF! What is the purpose of using the SendKeys command?
 
The Sendkeys command was a first attempt at hiding the navigation pane. It causes the pane to close. I really need to delete it, but it wasn't hurting anything, so I've left it in.

Hank
 
The Sendkeys command was a first attempt at hiding the navigation pane. It causes the pane to close. I really need to delete it, but it wasn't hurting anything, so I've left it in.

Hank
Hi Hank. So, if you take out the Sendkeys and MsgBox lines, the code doesn't work?
 
You take out the MsgBox, and the code doesn't work.

I'll give a try at removing the SendKeys, and see what that does.

Hank
 
The Sendkeys command was a first attempt at hiding the navigation pane. It causes the pane to close. I really need to delete it, but it wasn't hurting anything, so I've left it in.

Hank
Hi Hank. I just tested it out using the following (copied from your post above), and it worked for me.
Code:
Private Sub Form_Open(Cancel As Integer)
Call DoCmd.NavigateTo("acNavigationCategoryObjectType")
'hide the selected object
Call DoCmd.RunCommand(acCmdWindowHide)
'hide the tool ribbon
DoCmd.ShowToolbar "Ribbon", acToolbarNo
End Sub
 
Your suggestion about SendKeys was right on point--I commented both it and the MsgBox out, and now the code is working without the stop for the MsgBox.

Thanks!

Hank
 
Your suggestion about SendKeys was right on point--I commented both it and the MsgBox out, and now the code is working without the stop for the MsgBox.

Thanks!

Hank
Hi. Glad to hear you got it sorted out. Good luck with your project.
 
Sometimes, its a timing thing. Access needs to "catch up", and waiting for a msgbox to be dismissed can give you that time.

For the same reason (maybe it's a different reason), judicious use of "doevents" can help issues such as repainting the screen.
 
Sometimes, its a timing thing. Access needs to "catch up", and waiting for a msgbox to be dismissed can give you that time.

For the same reason (maybe it's a different reason), judicious use of "doevents" can help issues such as repainting the screen.
Haven't heard of Sendkeys causing delay either, but maybe...
 

Users who are viewing this thread

Back
Top Bottom