Error: Compile Error,ByRef argument type mismatch

Joined
May 18, 2017
Messages
2
Reaction score
0
Code:
Option Compare Database

Private Sub AddtoWhere(FieldValue As Variant, FieldName As String, mycriteria As Integer, argcount As Integer)
    
    '  Create criteria for WHERE clause.
    If FieldValue <> "" Then
        '  Add "and" if other criterion exists.
        If argcount > 0 Then
            mycriteria = mycriteria & " and "
        End If

        '  Append criterion to existing criteria.
        '  Enclose FieldValue and asterisk in quotation marks.
        mycriteria = (mycriteria & FieldName & " Like " & Chr(34) & Chr(42) & Chr(34))
        
        '  Increase argument count.
        argcount = argcount + 1
    End If

End Sub

Private Sub cmdsearch1_Click()

Dim Search As String
here:
    argcount = 0

    '  Initialize SELECT statement.
    mysql = "SELECT * FROM tblCapCrstab WHERE "
    mycriteria = ""

    '  Use values entered in text boxes in form header to create criteria for WHERE clause.
    'AddtoWhere cboCountry, "Country", mycriteria, argcount
    
    AddtoWhere cboProduct1, "Product", mycriteria, argcount
    'AddtoWhere cboYear1, "Years", mycriteria, argcount
    AddtoWhere cboptype1, "PType", mycriteria, argcount
    AddtoWhere cboSource1, "Source", mycriteria, argcount

    If mycriteria = "" Then
    mycriteria = True
 
    End If
    
    mysource = mysql & mycriteria

    Dim strval As String
   'set the recordsource of the subform to the resultset
    Me!sfrmtblCapCrstab.Form.RecordSource = mysource
    
Exit_cmdsearch1_Click:
    Exit Sub
Err_cmdsearch1_Click:
DoCmd.Hourglass False
DoCmd.Echo True
    MsgBox Err.Description & " Person Search Command Cancelled", vbInformation, "Person Search Command Cancelled"
    Resume Exit_cmdsearch1_Click
End Sub
I have an error that says "Compile Error,ByRef argument type mismatch" , can anyone let me know why this error occur or how to fix this?

Any help would be appreciated.

Thank you.
 
Back
Top