Check Blank Text Box Populated?

G

Guest

For some reason, I'm having difficulty verifying whether or not a text box is
populated. Here's what I have:

Text Box "faxnumber"
Check Box "sendfax"

When I check off "faxnumber", I first want to verify that there is fax
number entered. I'm running the beforeupdate event with the following code:

If Me.sendfax And me.faxnumber Like "" Then

MsgBox "The FAX NUMBER field must be populated before selecting SEND FAX"
Me.sendfax.undo

end if

I'm allowed to enter a check box in the "sendfax" check box. I also tried
the following:

If Me.sendfax And len(me.faxnumber) =< 0 Then

No success.

Any ideas?

Thanks in advance for your assistance.

Regards,

Gary
 
B

Brendan Reynolds

Try ...

If (Me.SendFax) And Len(Trim$(Me!FaxNumber & vbNullString)) > 0

This will successfully catch cases where the text box is Null, and empty
string, or contains nothing but spaces.

BTW: Notice the parentheses around Me.SendFax. There was a bug in at least
some versions of Access were implicit references to the value of a check
box, e.g. "If Me.SomeCheckBox Then" could cause Access to fail to close
afterward. Using parentheses like this is one way of avoiding that bug.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 

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