George Too
Registered User.
- Local time
- Today, 14:51
- Joined
- Aug 12, 2002
- Messages
- 198
I need help with creating a SQL statement that also displays null values.
I have a form with list boxes. The code below creates the SQL statement by reading the values from the lists:
For Each varItem In Me.lstMachine.ItemsSelected
strMachine = strMachine & ",'" & Me.lstMachine.ItemData(varItem) & "'"
Next varItem
'check the length of the resulting string and create a Like '*' or IN() statement
If Len(strMachine) = 0 Then
strMachine = "Like '*'"
Else
strMachine = Right(strMachine, Len(strMachine) - 1)
strMachine = "IN(" & strMachine & ")"
End If
'Get the Choices from the Option Buttons
If Me.OptAndDate.Value = True Then
strDateCondition = " AND "
Else
strDateCondition = " OR "
End If
Then variables are used to create the statement:
strSQL = "SELECT tblData.* FROM tblData WHERE " & _
"tblData.[Machine] " & strMachine & strDateCondition & _
"tblData.[Run_Date] " & strDate & ";"
This code works fine with the only problem that it does not pull null values. What should I add to it so it does?
Thanks,
George Too
I have a form with list boxes. The code below creates the SQL statement by reading the values from the lists:
For Each varItem In Me.lstMachine.ItemsSelected
strMachine = strMachine & ",'" & Me.lstMachine.ItemData(varItem) & "'"
Next varItem
'check the length of the resulting string and create a Like '*' or IN() statement
If Len(strMachine) = 0 Then
strMachine = "Like '*'"
Else
strMachine = Right(strMachine, Len(strMachine) - 1)
strMachine = "IN(" & strMachine & ")"
End If
'Get the Choices from the Option Buttons
If Me.OptAndDate.Value = True Then
strDateCondition = " AND "
Else
strDateCondition = " OR "
End If
Then variables are used to create the statement:
strSQL = "SELECT tblData.* FROM tblData WHERE " & _
"tblData.[Machine] " & strMachine & strDateCondition & _
"tblData.[Run_Date] " & strDate & ";"
This code works fine with the only problem that it does not pull null values. What should I add to it so it does?
Thanks,
George Too