Message Box Help

  • Thread starter Thread starter Gilberto Lawas via AccessMonster.com
  • Start date Start date
G

Gilberto Lawas via AccessMonster.com

To All Code Guru's,

I'm trying to make and IF THEN statement that says:

Dim stDocName As String

If AcctNum Is Null Then
MsgBox VbMsgBoxStyle=VbOKOnly As VbMsgBoxResult

Else
stDocName = "Credit Letter"
DoCmd.OpenReport stDocName, acPreview
End If

My problem is the Message box. All I want to say is if there is no account
Number then prompt user.
 
Actually, you're got 2 errors.

You should be using the IsNull function in VBA code:

If IsNull(AcctNum) Then

Second, though, your syntax is incorrect for the MsgBox statement.

According to the Help file, the syntax is:

MsgBox(prompt[, buttons] [, title] [, helpfile, context])

You probably want something like:

MsgBox "Account Number is Null", vbOkOnly + vbCritical, "Error!"
 
Thanks for the help.

I'll type that in as see how it works.

r/s
G.Lawas
 
Back
Top