VBA if textbox is null

G

ghetto_banjo

in VBA, i have an if statement checking to see if a text box is empty,
if it is i want to display a msgbox. seemingly not working if I use
Is Null, = Null, or = "". No default value on the textbox.

if me.text5 = "" then.....
This simply calculates the if statement as False when the text box is
empty.

if me.text5 is Null then...
This results in a Run-Time Error 424 Object Required on that line.

if me.text5 = Null then...
this once agains calculates if statement as False




what am i not seeing here....
 
F

fredg

in VBA, i have an if statement checking to see if a text box is empty,
if it is i want to display a msgbox. seemingly not working if I use
Is Null, = Null, or = "". No default value on the textbox.

if me.text5 = "" then.....
This simply calculates the if statement as False when the text box is
empty.

if me.text5 is Null then...
This results in a Run-Time Error 424 Object Required on that line.

if me.text5 = Null then...
this once agains calculates if statement as False

what am i not seeing here....
There is a difference between a field being Null and it containing a
zero length string, i.e. =""

Check for both.

If IsNull(Me![Text5]) Or Me![Text5] = "" Then
 
J

Jeff Boyce

It all starts with the data...

What data is supposed to be there? Is the textbox bound to a field in a
table?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

ghetto_banjo

Thats it thanks.

i needed to do the IsNull(text) as opposed to text Is Null.




Thanks again!
 

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