skwilliams
Registered User.
- Local time
- Today, 10:35
- Joined
- Jan 18, 2002
- Messages
- 516
I'm getting a type mismatch error on this section of code.
Any ideas??
Any ideas??
Code:
Private Sub btnOK_Click()
Dim varItem As Variant
Dim strDate As Date
Dim strCat As String
Dim strOrderNumber As String
Dim strCatCondition As String
Dim strOrderCondition As String
Dim strSQL As String
For Each varItem In Me.lstDate.ItemsSelected
strDate = strDate & ",#" & Me.lstDate.ItemData(varItem) & "#"
Next varItem
If Len(strDate) = 0 Then
strDate = "Like #*#"
Else
strDate = Right(strDate, Len(strDate) - 1)
strDate = "IN(" & strDate & ")"
End If
For Each varItem In Me.lstCat.ItemsSelected
strCat = strCat & ",'" & Me.lstCat.ItemData(varItem) & "'"
Next varItem
If Len(strCat) = 0 Then
strCat = "Like '*'"
Else
strCat = Right(strCat, Len(strCat) - 1)
strCat = "IN(" & strCat & ")"
End If
For Each varItem In Me.lstOrderNumber.ItemsSelected
strOrder = strOrder & ",'" & Me.lstOrderNumber.ItemData(varItem) & "'"
Next varItem
If Len(strOrder) = 0 Then
strOrder = "Like '*'"
Else
strOrder = Right(strOrder, Len(strOrder) - 1)
strOrder = "IN(" & strOrder & ")"
End If
If Me.optAndCat.Value = True Then
strCatCondition = " AND "
Else
strCatCondition = " OR "
End If
If Me.OptAndOrder.Value = True Then
strOrderCondition = " AND "
Else
strOrderCondition = " OR "
End If
strSQL = "SELECT tblMain.* FROM tblMain " & "WHERE tblMain.[dtDate] " & strDate & strCatCondition & "tblMain.[Cat] " & strCat & strOrderCondition & "tblMain.[OrderNumber] " & strOrderNumber
MsgBox strSQL
End Sub