Error 3464

jamesWP

Registered User.
Local time
Today, 15:35
Joined
Aug 8, 2005
Messages
68
Hi there,

I'm currently getting this error
Code:
Run-time error '3464'

Data type mismatch in criteria expression

My Code causing this is

Code:
Private Sub Label35_Click()
Dim Weekno As String
Dim repStr As String
Weekno = InputBox("For Week Number...", "Enter Week Number")
repStr = "[Companies_CompanyID] = " & Me.CompanyID _
& " and [Complete] = Yes" & " and [WeekNumber] = " & Weekno
Debug.Print repStr
DoCmd.OpenReport "Invoice", acViewPreview, , repStr 'This Line
End Sub

If I had no data matching the criteria it would simply load up an empty report, once I have data matching the criteria it brings up this error.

repStr works out as
Code:
[Companies_CompanyID] = 1 and [Complete] = Yes and [WeekNumber] = 30

Thanks Guys :)

Edit: Just incase it's important, the report opens just fine if opened manually.
 
Last edited:
For starters, I think you need quotes around the companyID so that it is evaluated as a string....


Code:
Private Sub Label35_Click()
Dim Weekno As String
Dim repStr As String
Weekno = InputBox("For Week Number...", "Enter Week Number")
repStr = "[Companies_CompanyID] = '" & Me.CompanyID _ &
"' and [Complete] = Yes" & " and [WeekNumber] = '" & Weekno
Debug.Print repStr
DoCmd.OpenReport "Invoice", acViewPreview, , repStr 'This Line
End Sub
 
This gives me
Code:
Syntax error in string in query expression '([Companies_CompanyID] = '1' and [Complete] = Yes and [WeekNumber] = '30)'.

Edit:

I shouldn't be so lazy and should've read through your code, now the error is
Code:
Data type mismatch in criteria expression.
 
Last edited:
Thanks :), turns out I needed the quotation mark on the last value :).
 
So you have [WeekNumber] set up as a string instead of a numeric fld?
 
Yeah, no idea why I did that, I guess I'll leave it like that now. :o
 
Hum... I guess someday you may want to a calculation on the fld... Maybe find the difference in weeks between two records (?)
 
Nah, basically its just to check what week an orders due. Thanks for your help though :).
 

Users who are viewing this thread

Back
Top Bottom