IsNull and Len(Nz Not Working

  • Thread starter bhipwell via AccessMonster.com
  • Start date
B

bhipwell via AccessMonster.com

I have a button function by which users can click to make sure they have
filled all the necessary fields. I want the code to run and turn the back
color to red. Here is my code...

If Len(Nz(Me.Field,"")=0) Then
Me.Field.backcolor = 1777215
End if

The issue is that it is not recognizing that the field is visibly blank
(understanding there may be a zero string).

I have tried the Len(Trim(Nz to no avail as well as IsNull. Any ideas?

BH
 
D

Douglas J. Steele

Your parentheses are incorrect.

It should be

If Len(Nz(Me.Field,""))=0 Then
Me.Field.backcolor = 1777215
End if

or

If Len(Me.Field & "")=0 Then
Me.Field.backcolor = 1777215
End if
 
J

Jeff Boyce

To troubleshoot this expression, I'd try using it in a query to see what it
is producing...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
B

bhipwell via AccessMonster.com

Code is still not working (I had paranteses correct, just posted here
incorrectly). If I go into the field and enter data, then delete it, the
code then works and produces the results I am looking for.

So then, what is in the field when I first open the form?

As an FYI, I cannot clear all fields upon opening as it is pulling data from
a table and displaying information.

Thanks in advance.

BH
 
T

tkelley via AccessMonster.com

Which event do you have your code in?
I have a button function by which users can click to make sure they have
filled all the necessary fields. I want the code to run and turn the back
color to red. Here is my code...

If Len(Nz(Me.Field,"")=0) Then
Me.Field.backcolor = 1777215
End if

The issue is that it is not recognizing that the field is visibly blank
(understanding there may be a zero string).

I have tried the Len(Trim(Nz to no avail as well as IsNull. Any ideas?

BH
 
B

bhipwell via AccessMonster.com

Just a button - on click.

Basically, I want the user to complete the form then click the button to
review what items may have been missed.

BH
 

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