Error: Compile Error,ByRef argument type mismatch

Discussion in 'Microsoft Office' started by abc1993, May 18, 2017.

  1. abc1993

    abc1993

    Joined:
    May 18, 2017
    Likes Received:
    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.
     
    abc1993, May 18, 2017
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. dikki

    Access "invalid argument" in ACCESS mdbs

    dikki, Nov 22, 2005, in forum: Microsoft Office
    Replies:
    0
    Views:
    422
    dikki
    Nov 22, 2005
  2. mamintihu

    Outlook Outlook 2007 - The Command Line argument is not valid

    mamintihu, Apr 15, 2008, in forum: Microsoft Office
    Replies:
    0
    Views:
    5,737
    mamintihu
    Apr 15, 2008
  3. nickvelissarides

    Excel Excel 2003 Compile error

    nickvelissarides, Nov 9, 2009, in forum: Microsoft Office
    Replies:
    2
    Views:
    644
    nickvelissarides
    Nov 18, 2009
  4. NFuller

    Excel VBA in Excel 07 Line Style Cap Type

    NFuller, Dec 11, 2009, in forum: Microsoft Office
    Replies:
    1
    Views:
    2,712
    daveydoom
    Dec 12, 2009
  5. mgjdun
    Replies:
    1
    Views:
    663
    mgjdun
    Nov 2, 2011
  6. actuarygirl

    Access DATA Type ACCESS

    actuarygirl, Jun 21, 2012, in forum: Microsoft Office
    Replies:
    1
    Views:
    778
    goodfellow
    Jun 21, 2012
  7. farkaserik

    PowerPoint PowerPoint: "can't open the type of file represented by..."

    farkaserik, Jul 9, 2015, in forum: Microsoft Office
    Replies:
    1
    Views:
    756
    muckshifter
    Jul 9, 2015
  8. Frencey Wilson

    Cannot type in Word

    Frencey Wilson, Jan 20, 2017, in forum: Microsoft Office
    Replies:
    1
    Views:
    321
    Becky
    Jan 21, 2017
Loading...