Questionable DIM Type

D

DS

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
 
K

Klatuu

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
 
D

DS

Klatuu said:
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
Thnks for the reply.
MenuID, TerminalID and StartDay are all Numeric, So the first code you
wrote is correct.
So the LSun would be either be -1 True or 0 False. I know its not a
date so it must be an integer?
Thanks for your help
DS
 
D

DS

DS said:
Klatuu said:
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
Thnks for the reply.
MenuID, TerminalID and StartDay are all Numeric, So the first code you
wrote is correct.
So the LSun would be either be -1 True or 0 False. I know its not a
date so it must be an integer?
Thanks for your help
DS
How This?
Dim LSun As Boolean
LSun = Nz(DLookup("StartDay", "MenuDetails", "MenuID = " &
Me.TxtMenuID & "And TerminalID =" & Me.TerminalID & "And StartDay = 1"), 0)
If LSun = True Then
Me.CheckSun = True
ElseIf Me.CheckSun = False Then
End If

I have one of these for each day of the week and when yuo click on a
command button it populates a series of check boxes.
Thanks
DS
 
K

Klatuu

That wont work. 1 will not evaluate to True, True is -1. This will:
If LSun = 1 Then
Me.CheckSun = True
ElseIf Me.CheckSun = 0 Then


DS said:
DS said:
Klatuu said:
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
Thnks for the reply.
MenuID, TerminalID and StartDay are all Numeric, So the first code you
wrote is correct.
So the LSun would be either be -1 True or 0 False. I know its not a
date so it must be an integer?
Thanks for your help
DS
How This?
Dim LSun As Boolean
LSun = Nz(DLookup("StartDay", "MenuDetails", "MenuID = " &
Me.TxtMenuID & "And TerminalID =" & Me.TerminalID & "And StartDay = 1"), 0)
If LSun = True Then
Me.CheckSun = True
ElseIf Me.CheckSun = False Then
End If

I have one of these for each day of the week and when yuo click on a
command button it populates a series of check boxes.
Thanks
DS
 
D

DS

Klatuu said:
That wont work. 1 will not evaluate to True, True is -1. This will:
If LSun = 1 Then
Me.CheckSun = True
ElseIf Me.CheckSun = 0 Then


:

DS said:
Klatuu wrote:


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


Thnks for the reply.
MenuID, TerminalID and StartDay are all Numeric, So the first code you
wrote is correct.
So the LSun would be either be -1 True or 0 False. I know its not a
date so it must be an integer?
Thanks for your help
DS

How This?
Dim LSun As Boolean
LSun = Nz(DLookup("StartDay", "MenuDetails", "MenuID = " &
Me.TxtMenuID & "And TerminalID =" & Me.TerminalID & "And StartDay = 1"), 0)
If LSun = True Then
Me.CheckSun = True
ElseIf Me.CheckSun = False Then
End If

I have one of these for each day of the week and when yuo click on a
command button it populates a series of check boxes.
Thanks
DS
Thanks,
Its working now.
DS
 

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