Results 1 to 2 of 2

Thread: Mismatch Error

  1. #1
    Join Date
    Apr 2006

    Unanswered: Mismatch Error

    Dear Sir/Madam
    I am trying to filter from a ADODC control where there are two fields to filter from two Combo controls. I have tried different variations of the below, but at the very least I get the Type Mismatch error:

    AdoUmpInfo.Recordset.Filter = "Umpire=' " + CStr(CboUmpNames.Text) + " ' " And AdoUmpInfo.Recordset.Filter = "Venue = '" + CStr(CboVenue.Text + "'")

    I don't know whether it has anything to do with the Quotes " " or the apostrahpes ' ' ? But I have tried mixing these combinations around and no results.

    Yet strangely enough (for me) if I try a single filter, it works, thus:
    AdoUmpInfo.Recordset.Filter = "Venue ='" + CboVenue.Text + "' "

    Any suggestions on correcting this error would be extremely grateful.

    My home e-mail is

    Regards Peter Taylor

  2. #2
    Join Date
    Jun 2004
    Arizona, USA
    A couple of points.

    First, you should always use the string concatenation operator (&) to concatenate strings in VB. While the plus operator usually works as you anticipate, there ARE instances when it doesn't. Why not use the string concatenation operator, and remove all doubt?

    Second - what are the field types in the database? Remember, only text fields and date fields use delimiters. Numeric fields must NOT use them.

    Third - try this...

    AdoUmpInfo.Recordset.Filter = "Umpire='" & CStr(CboUmpNames.Text) & "' And Venue = '" & CStr(CboVenue.Text) & "'"
    The filter property should resemble the where clause of a SQL select statement. There were actually a couple of issues here.

    First, you moved the closing paren from the last CStr function outside the string. Second, you included a second instance of adoumpinfo.recordset.filter actually inside the string you were trying to build. Third, you included extra spaces between the apostrophes and the data.

    A useful technique is to use a temporary string in building up your SQL statements and filters, so you can easily look at them in the debug mode.

    Dim strSQL as string
    strSQL = "Umpire='" & CStr(CboUmpNames.Text) & "' And Venue = '" & CStr(CboVenue.Text) & "'"
    AdoUmpInfo.Recordset.Filter = strSQL
    Using the above approach, you can pause the mouse over variable strSQL in the debug mode, and the value of the string inside the variable will be displayed.
    Last edited by loquin; 04-19-06 at 16:02.
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert

Posting Permissions

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