Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combox search causes Type Mismatch error 13

Status
Not open for further replies.

lastout

Programmer
Apr 12, 2002
84
US
I keep running into Type Mismatch error 13 (is this really a bug in the program?) when I try to use the standard combobox code to find a record based on the selection in the combobox but add in a line to turn off any pre-existing filters. The code is:

Dim rs As Object

Me.FilterOn = False

Set rs = Me.Recordset.Clone
rs.FindFirst "[PartnerID] = " & Str(Nz(Me![cmbSearchbyPartnerName], 5))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

After getting the Type Mismatch error message, the debugger highlights the rs.FindFirst line.

I have tried Dim rs As DAO.Recordset with the DAO 3.6 library checked above the ADO library in References, but that doesn?t fix it.

If I remove the FilterOn = False line, the combobox works fine. Problem is, the user can search for a record in this form a number of different ways that result in filtering, or the form might be opened from another form which filters the records based on the record selected in the calling form, so I need to be able to switch off any filters whenever a new search is performed.

I wonder if it's somehow because of the Str function? Though if it is, why would it work when the FilterOn = False line is removed?

The strangest thing is, I kept getting this error msg a few days ago and I worked and worked on the module and at the end of the day yesterday this code and all the other search code worked perfectly, no hitches. When I went back today to test it out again, it was right back to square one as if yesterday was all in my imagination??? It's not as though I changed anything in my sleep!!! lastout (the game's not over till it's over)
 
This is ADO syntax and it is a type mismatch.

Set rs = Me.Recordset.Clone

Always Dim as a recordset not an object.
Dim rs as DAO.recordset
or
Dim rs as ADODB.recordset

DAO
Set rs = Me.RecordSetClone
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top