Testing for Null value in Txtbox

  • Thread starter Thread starter PMC1
  • Start date Start date
P

PMC1

Hi,

Quick query!

I have a form with txtbox "txtCoName". The code behind a command button
on this form has an if..then as follows:

If me.txtcoName.Value = Null then
Do stuff
Else
Do Some other stuff
End if

The problem is when this txtbox is blank the first part of the if
statement incorrectly proves false. I can see this by placing a
breakpoint at this statement and using intelliprompt I can see the
value of the txtbox is Null but the code below is ignored and the
"else" part of the statement is evaluated. How is this possible?


Thanks
 
Hi,

Quick query!

I have a form with txtbox "txtCoName". The code behind a command button
on this form has an if..then as follows:

If me.txtcoName.Value = Null then
Do stuff
Else
Do Some other stuff
End if

The problem is when this txtbox is blank the first part of the if
statement incorrectly proves false. I can see this by placing a
breakpoint at this statement and using intelliprompt I can see the
value of the txtbox is Null but the code below is ignored and the
"else" part of the statement is evaluated. How is this possible?

Thanks

If IsNull(me.txtcoName.Value) then
etc....

And ... since Value is the default property you can omit it:
If IsNull(me.txtcoName) then
 

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

Back
Top