Need a msgbox when text box is empty

W

worksfire1

For some reason, this simple thing is getting me. I have a form that a user
will type an account # in a text box in then click a button to open a new
form. It is an unbound text box with no calculations on it or anything. If
it is empty/blank/null, then I want a message box to pop up telling them they
need to type something in that text box before proceeding.

I have tried is Null: only to get Access Error "Object Required."
Private Sub cmdAddMissingCPrequest_Click()
If Forms![frmBiller-MissingChargesinCP]!txtAccount Is Null Then
MsgBox "Please enter an account # to proceed."
Else
DoCmd.OpenForm "frmBiller-ROEsAndOracle#sList"
DoCmd.Maximize
End If
End Sub

Also, tried ="" : and it goes on to the form when I want it to pop up a
message!
Private Sub cmdAddMissingCPrequest_Click()
If Forms![frmBiller-MissingChargesinCP]!txtAccount = "" Then
MsgBox "Please enter an account # to proceed."
Else
DoCmd.OpenForm "frmBiller-ROEsAndOracle#sList"
DoCmd.Maximize
End If
End Sub
 
S

Steve

Try IsNull(Forms![frmBiller-MissingChargesinCP]!txtAccount)

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
P

Paolo

Hi worksfire,

If isnull(Forms![frmBiller-MissingChargesinCP]!txtAccount) or
Forms![frmBiller-MissingChargesinCP]!txtAccount = "" Then
msgbox "blah blah blah" etc. etc

in this way you check both cases (null or blank) with just an if

HTH Paolo
 
W

worksfire1

Thank you!!!!

Just curious, why did it not work the way I had written the IF .... is null
statement?

Steve said:
Try IsNull(Forms![frmBiller-MissingChargesinCP]!txtAccount)

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




worksfire1 said:
For some reason, this simple thing is getting me. I have a form that a
user
will type an account # in a text box in then click a button to open a new
form. It is an unbound text box with no calculations on it or anything.
If
it is empty/blank/null, then I want a message box to pop up telling them
they
need to type something in that text box before proceeding.

I have tried is Null: only to get Access Error "Object Required."
Private Sub cmdAddMissingCPrequest_Click()
If Forms![frmBiller-MissingChargesinCP]!txtAccount Is Null Then
MsgBox "Please enter an account # to proceed."
Else
DoCmd.OpenForm "frmBiller-ROEsAndOracle#sList"
DoCmd.Maximize
End If
End Sub

Also, tried ="" : and it goes on to the form when I want it to pop up a
message!
Private Sub cmdAddMissingCPrequest_Click()
If Forms![frmBiller-MissingChargesinCP]!txtAccount = "" Then
MsgBox "Please enter an account # to proceed."
Else
DoCmd.OpenForm "frmBiller-ROEsAndOracle#sList"
DoCmd.Maximize
End If
End Sub
 
W

worksfire1

Thank you!!! That works.

Paolo said:
Hi worksfire,

If isnull(Forms![frmBiller-MissingChargesinCP]!txtAccount) or
Forms![frmBiller-MissingChargesinCP]!txtAccount = "" Then
msgbox "blah blah blah" etc. etc

in this way you check both cases (null or blank) with just an if

HTH Paolo

worksfire1 said:
For some reason, this simple thing is getting me. I have a form that a user
will type an account # in a text box in then click a button to open a new
form. It is an unbound text box with no calculations on it or anything. If
it is empty/blank/null, then I want a message box to pop up telling them they
need to type something in that text box before proceeding.

I have tried is Null: only to get Access Error "Object Required."
Private Sub cmdAddMissingCPrequest_Click()
If Forms![frmBiller-MissingChargesinCP]!txtAccount Is Null Then
MsgBox "Please enter an account # to proceed."
Else
DoCmd.OpenForm "frmBiller-ROEsAndOracle#sList"
DoCmd.Maximize
End If
End Sub

Also, tried ="" : and it goes on to the form when I want it to pop up a
message!
Private Sub cmdAddMissingCPrequest_Click()
If Forms![frmBiller-MissingChargesinCP]!txtAccount = "" Then
MsgBox "Please enter an account # to proceed."
Else
DoCmd.OpenForm "frmBiller-ROEsAndOracle#sList"
DoCmd.Maximize
End If
End Sub
 
S

Steve

Is Null amd Is Not null are expressions that can only be used in the
criteria of fields in a query.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




worksfire1 said:
Thank you!!!!

Just curious, why did it not work the way I had written the IF .... is
null
statement?

Steve said:
Try IsNull(Forms![frmBiller-MissingChargesinCP]!txtAccount)

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




worksfire1 said:
For some reason, this simple thing is getting me. I have a form that a
user
will type an account # in a text box in then click a button to open a
new
form. It is an unbound text box with no calculations on it or
anything.
If
it is empty/blank/null, then I want a message box to pop up telling
them
they
need to type something in that text box before proceeding.

I have tried is Null: only to get Access Error "Object Required."
Private Sub cmdAddMissingCPrequest_Click()
If Forms![frmBiller-MissingChargesinCP]!txtAccount Is Null Then
MsgBox "Please enter an account # to proceed."
Else
DoCmd.OpenForm "frmBiller-ROEsAndOracle#sList"
DoCmd.Maximize
End If
End Sub

Also, tried ="" : and it goes on to the form when I want it to pop up a
message!
Private Sub cmdAddMissingCPrequest_Click()
If Forms![frmBiller-MissingChargesinCP]!txtAccount = "" Then
MsgBox "Please enter an account # to proceed."
Else
DoCmd.OpenForm "frmBiller-ROEsAndOracle#sList"
DoCmd.Maximize
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top