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

MESSAGE BOX ERROR

Status
Not open for further replies.

Kevsim

Instructor
Apr 18, 2000
385
AU
I am trying to have a message box appear that has 2 buttons for response, Yes and No, for the user to make a selection. I am using the following code but an error message appears stating “Compile Error, Invalid Qualifier” and highlites MsgBox. I am using Access 2000 and would appreciate assistance in correcting my error.
Private Sub Form_Close()
Dim UserSelection
UserSelection = MsgBox ("This will end your session").vbYesNo + vbQuestion("Are You Sure")
kevsim
 
HI,

I see a couple of things that jump out at me.

You wrote:

"Dim UserSelection
UserSelection = MsgBox ("This will end your session").vbYesNo + vbQuestion("Are You Sure")"

There is a period before the vbYesNo that should be a comma. I dont know if that is just a miss type or is actually in your code wrong.

Here is the way it should look:

'**************************
Private Sub Form_Close()

msgbox ("This will end your session"), vbYesNo + vbQuestion, "Are You Sure"

End Sub
'****************************

Also, why are you setting the message box to a variable? Given just what you have posted, you dont need to set a variable. Well, you will need to put some more code in here for this to work correctly. Currently, the form is going to close no matter which button you pick. If you need some more help, post back and let me know. I will try to assist.

Have a great day!!

Nathan
Senior Test Manager
 
nathan1967, thank you for the advise, it works great.
kevsim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top