Not is Null code not working

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Not is Null code not working

Post by Leesha »

Hi,
I have [frmStoreDemographicsUpdate] that opens from [frmStoreDemographicsLookup]. [frmStoreDemographicsLookupLog] also opens to store info for requerying [frmStoreDemographicsUpdate]. All of this works fine. If txtStoreStatusEndDate on [frmStoreDemographicsLookupLog] is null, cmdEnable should not be disabled. If there is a date in txtStoreStatusendDate, cmdEnable should be disabled. The code isn't working. I've uploaded a stripped down version of the database.

Thanks,
Leesha
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78547
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Not is Null code not working

Post by HansV »

The text box isn't null, it contains the empty string "". Try this line:

ElseIf Nz(Forms!sfrmStoreDemographicsLookupLog!txtStatusEndDate) <> "" Then
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Re: Not is Null code not working

Post by Leesha »

That worked perfectly! I didn't realize you could use Nz for anything but numbers. Does it work with text as well?

Thanks!
Leesha

User avatar
HansV
Administrator
Posts: 78547
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Not is Null code not working

Post by HansV »

Yes, you can use Nz with text fields/controls too. There are two forms:

Nz(expression) returns expression unless that is Null, then it returns an empty string "". It is equivalent to Nz(expression, "").

Nz(expression, "alternative") returns expression unless that is Null, then it returns "alternative".
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Re: Not is Null code not working

Post by Leesha »

Thanks for the info. Ahhhhh, the possiblities!
Leesha