Your post is confusing. You say it is Yes/No (Boolean data type), but
it looks like you may be using it as a date, but then you are looking
in StartDay for a value of 1. Can't figure out from this what it is
you are trying to do. Some things I notice about your code:
MenuID would have to be a numeric data type for this to work.
TeminalID would have to be a numeric data type for this to work.
I have rewritten your code based on what I think you are doing:
If IsNull(DLookup("[StartDay]", "MenuDetails", "[MenuID] = " & _
Me.txtMenuID & " And [TerminalID] = " & Me.TerminalID & _
" [StartDay] = 1") Then
Me.CheckSun = True
Else
Me.CheckSun = False
End If
Some additional notes:
1. Use the VBA contstants (True not -1, False not 0) it makes your
code easier to read.
2. Enclose table field names in brackets []. It makes what they are
obvious and avoids any ambiguity
3. The code above assumes MenuID, TeminalID, and StartDay are all
numeric fields. If any are text, you will need to make the following
changes. In the example below, I am assuming StartDay is numeric and
the other fields are text.
If IsNull(DLookup("[StartDay]", "MenuDetails", "[MenuID] = '" & _
Me.txtMenuID & "' And [TerminalID] = '" & Me.TerminalID & _
"' [StartDay] = 1") Then
Me.CheckSun = True
Else
Me.CheckSun = False
End If
:
LSun is a Yes/No answer.... CheckSum is a CheckBox, I think I have
DIM as a wrong DIM As
Should it be something else?
Dim LSun As Date
LSun = Nz(DLookup("StartDay", "MenuDetails", "MenuID = " &
Me.TxtMenuID & "And TerminalID =" & Me.TerminalID & "And StartDay =
1"), 0)
If LSun > 0 Then
Me.CheckSun = -1
ElseIf Me.CheckSun = 0 Then
End If
Thanks
DS