Code doesn't work without MsgBox (1 Viewer)

dionwr

New member
Local time
Today, 06:39
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
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:39
Joined
Oct 29, 2018
Messages
21,357
Hi. Welcome to AWF! What is the purpose of using the SendKeys command?
 

dionwr

New member
Local time
Today, 06:39
Joined
Dec 1, 2019
Messages
4
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
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:39
Joined
Oct 29, 2018
Messages
21,357
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?
 

dionwr

New member
Local time
Today, 06:39
Joined
Dec 1, 2019
Messages
4
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
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:39
Joined
Oct 29, 2018
Messages
21,357
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
 

dionwr

New member
Local time
Today, 06:39
Joined
Dec 1, 2019
Messages
4
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
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:39
Joined
Oct 29, 2018
Messages
21,357
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.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 13:39
Joined
Sep 12, 2006
Messages
15,613
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.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:39
Joined
Oct 29, 2018
Messages
21,357
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

Top Bottom