[Question] Dlookup date criteria that is null

sunset1215

Registered User.
Local time
Today, 21:22
Joined
Apr 7, 2011
Messages
46
[Solved] Dlookup date criteria that is null

hi. i'm assigning and returning thumbdrives using 2 command buttons. so now i want to disable the assign button when they already have a thumbdrive assigned. my code is this:

Code:
Form_current()
 
Dim HaveThb
HaveThb = DLookup("pkThbID", "tblThumbdrive", "[fkPerID] = " & Me.pkPerID & _
          [COLOR=red]" And IsNull([dtmThbIn])[/COLOR]")
 
If IsNull(HaveThb) Then
Me.cmdReturnThb.Enabled = False
Me.cmdAssignThb.Enabled = True
If Not IsNull(HaveThb) Then
Me.cmdAssignThb.Enabled = False
Me.cmdReturnThb.Enabled = True
Else
Me.cmdReturnThb.Enabled = False
End If
End If

i don't get any errors, but it doesn't enable/disable the buttons correctly. i think it might be the line highlighted in red that is the problem, as i could not find any example for date criteria that is null.

another question. for date fields when it is empty, is it null or is it a zero-length string? does the same apply when i delete a date value in it?

i appreciate any help or advice given.
 
Last edited:
after some trial and error, i got it to work. i apologize for not thinking more thoroughly before posting.

edited code here:
Code:
Form_current()
 
Dim HaveThb As Long
HaveThb = Nz(DLookup("pkThbID", "tblThumbdrive", "[fkPerID] = " & Me.pkPerID & _
          " And IsNull([dtmThbIn])"), 0)
 
If HaveThb = 0 Then
Me.cmdReturnThb.Enabled = False
Me.cmdAssignThb.Enabled = True
Else
Me.cmdAssignThb.Enabled = False
Me.cmdReturnThb.Enabled = True
End If
 

Users who are viewing this thread

Back
Top Bottom