Check if textbox is empty

James.uk

Access Newbie
Local time
Today, 06:07
Joined
Apr 23, 2004
Messages
16
Here's another simple one for you all; I need to check if a text box is empty and pop up a message if it is.

I have tried:
Code:
personID = Forms!Add!personID
    If personID Is Nothing Then
        MsgBox ("You must enter an ID number")
    Else...

and

Code:
personID = Forms!Add!personID
    If personID="" Then
        MsgBox ("You must enter an ID number")
    Else...

but neither work.

Any ideas?

Thanks again :)
 
If [personID] Is Null or [personID] like ""
 
hmm... didn't work.

The null method spawned an error, and the like method just went to the else bit of the statement. :confused:

I'm not having a very good day with Access am I? :)
 
Last edited:
Code:
If IsNull([YourTextBoxName]) or [YourTextBoxName] = "" Then
     MsgBox "Your text box is empty"
Else
     MsgBox "Your text box is not empty"
End If

The OR above will cover you in case they key something in the text box then delete it since the text box will no longer be Null. Also, do not use the name of the field, use the name of the text box object.

HTH
 
What is the error that was generated?
What if you stored the person ID in a variable?

Dim intID as integer
intID = [personID]
if Nz(intID, 0) = 0 then
show your message box
 

Users who are viewing this thread

Back
Top Bottom