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:
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.
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 17: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