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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying details by selecting item in combo box 1

Status
Not open for further replies.

8441

Technical User
May 9, 2001
54
GB
I am trying to create a form where the details of the record appear when the unique id is selected from the combo box.

I have a vehicle database with 2 tables. Vehicle data, which holds make, model, reg etc and the other table holds annual data, service costs, bodywork cost, mileage. The two tables are linked by regno field.

I would like to create the annual data form with a combo box listing all the registrations of vehicles in the database and then the make, model etc fields display the relevant details. The fields change if the combo box entry changes.

I had this working in another database where the key was a number field. The key in this db is a text field. I used the code below



dim rs as object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Reg_Number] = " & Str(Me![RegNo])
Me.Bookmark = rs.Bookmark


But when I try the above I get the error type mismatch on the middel line. It doesn't seem to like me having the key field a text.

Does anyone know how I can get this working with a text field.

Thanks
 
If you're findfirst is for a string you need

Set rs = Me.Recordset.Clone
rs.FindFirst "[Reg_Number] = '" & Str(Me![RegNo]) & "'"
Me.Bookmark = rs.Bookmark
 
I tried putting in the '" but still get a type mismatch error 13. My code is now


Dim rs As Object


Set rs = Me.Recordset.Clone
rs.FindFirst "[Reg_Number] = '" & Str(Me![RegNo]) & "'"
Me.Bookmark = rs.Bookmark

 
I don't know if this is the problem, however...
You could simplify this code. From what I can tell you don't need the str function, the Me (that's implied) or the square brackets. So you could have.......


Set rs = Me.Recordset.Clone
rs.FindFirst "Reg_Number = '" & RegNo & "'"
Me.Bookmark = rs.Bookmark

 
BRILLIANT. Thank you very much, that worked.

Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top