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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,318
Office Version
  1. 365
Platform
  1. Windows
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.
 
Joined
Mar 23, 2004
Messages
241
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:
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,097
Office Version
  1. 365
Platform
  1. Windows
Purely out of interest, what does ASFAIK stand for??
As far as I know...
 

Forum statistics

Threads
1,147,847
Messages
5,743,522
Members
423,801
Latest member
paulj4177

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