Easy Q: MsgBox help or examples needed!

Joined
Mar 23, 2004
Messages
241
Hi guys. I'm just cutting my teeth on VB in Access. I've tried using the help files and a book, but I don't understand how the MsgBox works in VB. I've got the following code, and I've tried every permutation of quotes, square brackets, etc, possible, but I get an error every time.

Could someone have a look at the Msgbox bit of the code and either tell me where I'm going wrong, or give me an example of code that uses the MsgBox command? I'd be ever so grateful... I hope the code should make it obvious what I'm trying to do...

Private Sub Date_Completed_AfterUpdate()
If Me.Date_Completed < Me.Last_Updated Then
MsgBox("The date you have entered is before the date the error was created. Please check the date and try again.", vbOkayOnly, "No!")
Else
End If
End Sub


Any help would, as always, be immensely appreciated. I am not worthy :pray:
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Billy

What is the actual problem?

Try

Code:
MsgBox "The date you have entered is before the date the error was created. Please check the date and try again.", vbOKOnly, "No!"

You only need the brackets if you want to return a value from the messagebox and ASFAIK vbOkayOnly isn't a VBA constant.
 
Upvote 0
Hi Norie.

Many many thanks for your help with that. All sorted now! You've also helped me understand the format used in the help files, so I should be a little more self-sufficient now, so thanks for that too...

Purely out of interest, what does ASFAIK stand for??

I'm not worthy. :pray:
 
Upvote 0

Forum statistics

Threads
1,222,043
Messages
6,163,565
Members
451,844
Latest member
ddnndd1234

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
Back
Top