Runtime Error 13 - Type Mismatch

jeran042

Registered User.
Local time
Yesterday, 18:07
Joined
Jun 26, 2017
Messages
127
Im sure Im missing something so obvious, but cant seem to troubleshoot it. I am getting a type mismatch on the following code:

Code:
Private Sub Text2_Click()

Dim iCost_Center As Integer
Dim sCategory As String
Dim sWhere As String
Dim sFormName As String


iCost_Center = Me.txtCOST_CENTER
sCategory = Me.txtTemp_Month_Temp_Per
sWhere = "[COST_CENTER] = " & iCost_Center And "[CATEGORY] = " & "'" & sCategory & "'"   'This is the line throwing up the error
sFormName = "frm: Ledger Detail"


DoCmd.OpenForm sFormName, acViewNormal, , sWhere, , acDialog


End Sub

Can someone point out what I'm doing wrong? :banghead:
Very much appreciated!!
 
I moved your post out of the moderated code repository forum.

For starters, the "And" needs to be inside the quotes; you have it outside.
 
Paul is right.

That is also the cause of your type mismatch. Since the "AND" is not quoted, what you are doing is the expression

Code:
iCost_Center And "[CATEGORY] = "

where you are doing the AND of an integer and a string constant. That is your mismatch.
 

Users who are viewing this thread

Back
Top Bottom