jumpy262000
asked on
MS Access type Mismatch in criteria expression
I'm receiving a run-time error "3464" Data type mismatch in criteria expression for line:
strSQL = strSQL & "[datDate] = '" & Me.datDate & "'"
me.datDate is a date value.
Dim DB As Database
Dim rs As Recordset
Dim strSQL As String
Set DB = CurrentDb
If IsNull(Me.datDate) Then
MsgBox "Please a date value"
Exit Sub
End If
strSQL = "Select * from tblNewReceipts Where"
strSQL = strSQL & "[datDate] = '" & Me.datDate & "'"
Set rs = DB.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
Me.Dept62BreakdownCost = rs!Dept62BreakdownCost
Me.Dept62BreakdownRetail = rs!Dept62BreakdownRetail
Me.Dept62NeedtoSortCost = rs!Dept62NeedtoSortCost
Me.Dept62NeedtoSortRetail = rs!Dept62NeedtoSortRetail
Me.Dept71BreakdownCost = rs!Dept71BreakdownCost
Me.Dept71BreakdownRetail = rs!Dept71BreakdownRetail
Me.Dept71NeedtoSortCost = rs!Dept71NeedtoSortCost
Me.Dept71NeedtoSortRetail = rs!Dept71NeedtoSortRetail
Me.Dept84BreakdownCost = rs!Dept84BreakdownCost
Me.Dept84BreakdownRetail = rs!Dept84BreakdownRetail
Me.Dept84NeedtoSortCost = rs!Dept84NeedtoSortCost
Me.Dept84NeedtoSortRetail = rs!Dept84NeedtoSortRetail
Me.Dept62Cost = rs!Dept62PalletsonFlooryby VendorCost
Me.Dept62Retail = rs!Dept62PalletsonFlooryby VendorReta il
Me.Dept71Cost = rs!Dept71PalletsonFlooryby VendorCost
Me.Dept71Retail = rs!Dept71PalletsonFlooryby VendorReta il
Me.Dept84Cost = rs!Dept84PalletsonFlooryby VendorCost
Me.Dept84Retail = rs!Dept84PalletsonFlooryby VendorReta il
Me.datDate = rs!datDate
rs.Close
DB.Close
Set rs = Nothing
Set DB = Nothing
strSQL = strSQL & "[datDate] = '" & Me.datDate & "'"
me.datDate is a date value.
Dim DB As Database
Dim rs As Recordset
Dim strSQL As String
Set DB = CurrentDb
If IsNull(Me.datDate) Then
MsgBox "Please a date value"
Exit Sub
End If
strSQL = "Select * from tblNewReceipts Where"
strSQL = strSQL & "[datDate] = '" & Me.datDate & "'"
Set rs = DB.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
Me.Dept62BreakdownCost = rs!Dept62BreakdownCost
Me.Dept62BreakdownRetail = rs!Dept62BreakdownRetail
Me.Dept62NeedtoSortCost = rs!Dept62NeedtoSortCost
Me.Dept62NeedtoSortRetail = rs!Dept62NeedtoSortRetail
Me.Dept71BreakdownCost = rs!Dept71BreakdownCost
Me.Dept71BreakdownRetail = rs!Dept71BreakdownRetail
Me.Dept71NeedtoSortCost = rs!Dept71NeedtoSortCost
Me.Dept71NeedtoSortRetail = rs!Dept71NeedtoSortRetail
Me.Dept84BreakdownCost = rs!Dept84BreakdownCost
Me.Dept84BreakdownRetail = rs!Dept84BreakdownRetail
Me.Dept84NeedtoSortCost = rs!Dept84NeedtoSortCost
Me.Dept84NeedtoSortRetail = rs!Dept84NeedtoSortRetail
Me.Dept62Cost = rs!Dept62PalletsonFlooryby
Me.Dept62Retail = rs!Dept62PalletsonFlooryby
Me.Dept71Cost = rs!Dept71PalletsonFlooryby
Me.Dept71Retail = rs!Dept71PalletsonFlooryby
Me.Dept84Cost = rs!Dept84PalletsonFlooryby
Me.Dept84Retail = rs!Dept84PalletsonFlooryby
Me.datDate = rs!datDate
rs.Close
DB.Close
Set rs = Nothing
Set DB = Nothing
ASKER
I received a Run time error 13, type mismatch for Line:
Set rs = DB.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
Set rs = DB.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or if [datDate] is text
strSQL = "Select * from tblNewReceipts Where "
strSQL = strSQL & "[datDate] = '" & Me.datDate & "'"
if date
strSQL = "Select * from tblNewReceipts Where "
strSQL = strSQL & "[datDate] = #" & Me.datDate & "#"
strSQL = "Select * from tblNewReceipts Where "
strSQL = strSQL & "[datDate] = '" & Me.datDate & "'"
if date
strSQL = "Select * from tblNewReceipts Where "
strSQL = strSQL & "[datDate] = #" & Me.datDate & "#"
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks to you both, hope the rest of you're morning goes well.
Glad to help :-)
strSQL = strSQL & "[datDate] = #" & Me.datDate & "#"