How to stop message box appears after the database is closed

Apple08

Active Member
Joined
Nov 1, 2014
Messages
384
Hi All

I have created the macros below and the message box appears twice while the form is loaded and also after the database is closed. I only want the message box to appear once when the form is load and once user has selected 'OK' then the message box should be disappeared and no longer required. Please could anyone help to point out my mistake:

VBA Code:
Private Sub Form_Load()

Application.RunCommand acCmdAppMaximize

DoCmd.ShowToolbar "Ribbon", acToolbarNo

Call SetEnabledState(False)

Call Menu_Load

Me.lblWelcome.Caption = "User: " & strPeopleName

' Sets the time in the 'userUseRecord' table when the user logs into the database
Call setLogin

'Restricts access to the database to LTI staff members
Call LTIstaffPermission

'Sets users editing permissions
Call setUsersEditingPermissions

Call Msg_Box

End Sub

Private Sub Msg_Box()

MsgBox "Please note the form is no longer in use.", vbInformation, "Important Information"

End Sub
 

Some videos you may like

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Micron

Well-known Member
Joined
Jun 3, 2015
Messages
2,058
Office Version
  1. 365
Platform
  1. Windows
Put a break point at the start of the code. Do whatever it is you're doing to run it and watch what happens line by line (F8). I see nothing in that code that should present a message box more than once. It is probably one of the many procedures that you're branching off to that's doing it.
 

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,824
Office Version
  1. 2019
Platform
  1. Windows
Agree with the above. Also, you might get this behavior if the form is actually loaded more than once.
 

welshgasman

Well-known Member
Joined
May 25, 2013
Messages
880
PMFJI,

Never been a fan of showing a user something, then saying they cannot use it?
I'd prefer to not show it in the first place?
 

Watch MrExcel Video

Forum statistics

Threads
1,127,531
Messages
5,625,368
Members
416,096
Latest member
forevans

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top