Results 1 to 6 of 6
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm getting a 'Run-time 13' Type mismatch message

    What's really aggravating is that I know I've done this in the distant past, but I can't even find it in the Forum. I believe that the problem is that the original code was for a numeric search, while in this case it needs to be for a non-numeric search.

    Private Sub fndClassNoForReport_Click()
    Dim rs As Object
    Set rs = Me.Recordset.Clone
    rs.FindFirst "[FNClass_ProgNo] = " & Str(Nz(Me![fndClassNoForReport], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub

    Thanks in advance for any help with this
    Cheers,
    Andy

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    If FNClass_ProgNo is a text field, you need to enclose the search value in quotes Chr(34):

    rs.FindFirst "[FNClass_ProgNo] = " & Chr(34) & Me![fndClassNoForReport] & Chr(34)

  3. #3
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='785285' date='19-Jul-2009 11:47']If FNClass_ProgNo is a text field, you need to enclose the search value in quotes Chr(34):

    rs.FindFirst "[FNClass_ProgNo] = " & Chr(34) & Me![fndClassNoForReport] & Chr(34)[/quote]

    Thanks kindly, Hans. Accurate, quick and patient as always
    Cheers,
    Andy

  4. #4
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='785285' date='19-Jul-2009 11:47']If FNClass_ProgNo is a text field, you need to enclose the search value in quotes Chr(34):

    rs.FindFirst "[FNClass_ProgNo] = " & Chr(34) & Me![fndClassNoForReport] & Chr(34)[/quote]
    OK, I may as well push my programming luck.

    As mentioned, your code suggestion worked perfectly and the selected code was selected. However, when I tried to use the selected code to run a report, it asked for a parameter value:

    SELECT [qry FNC_02_Classes].FNClass_ProgNo FROM [qry FNC_02_Classes];

    Private Sub fndClassNoForReport_Click()
    Dim rs As Object
    Set rs = Me.Recordset.Clone
    rs.FindFirst "[FNClass_ProgNo] = " & Chr(34) & Me![fndClassNoForReport] & Chr(34)
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub

    Private Sub Command3073_Click()
    Me.Refresh
    DoCmd.OpenReport "rpt FNC Courses - Adults", acViewPreview, , "FNClass_ProgNo= " & FNClass_ProgNo
    DoCmd.RunCommand acCmdZoom75
    End Sub

    I can hardly wait to find out what I'm not seeing!
    Cheers,
    Andy

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You should use quotes there too:

    DoCmd.OpenReport "rpt FNC Courses - Adults", acViewPreview, , "FNClass_ProgNo= " & Chr(34) & FNClass_ProgNo & Chr(34)

  6. #6
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='785290' date='19-Jul-2009 12:55']You should use quotes there too:

    DoCmd.OpenReport "rpt FNC Courses - Adults", acViewPreview, , "FNClass_ProgNo= " & Chr(34) & FNClass_ProgNo & Chr(34)[/quote]
    Hans, I doubt if there would be enough tranquilizers in this world, that would enable me to be able to do your job.

    Thanks again,
    Cheers,
    Andy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •