Can I select a record based off a comboBox

Jon123

Registered User.
Local time
Yesterday, 23:20
Joined
Aug 29, 2003
Messages
668
I have a form with a combobox that is linked to a box number I want to select a box value and then have that record displayed. I cant get the gotorecord on the after update working on that combobox it that the rightway to go about this?
 
I'm getting a type mismatch?

Code:
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Kit TOTE Number] = " & Str(Nz(Me![totenumber], 0))
 
Here's a sample that shows how I do this. The form opens empty. You choose a value from the combo and the form is requeried to show the selected record. It takes one line of code and a query with a where clause.
 

Attachments

I'm getting a type mismatch?

Code:
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Kit TOTE Number] = " & Str(Nz(Me![totenumber], 0))

If [Kit TOTE Number] is a numeric then try
Code:
rs.FindFirst "[Kit TOTE Number] = " & Nz(Me![totenumber], 0)

if it's text the combo box value needs to be in quotes so try

Code:
rs.FindFirst "[Kit TOTE Number] = '" & Nz(Replace(Me![totenumber],"'","''"), 0) & "'"

In either case the Str function shouldn't be necessary. The Replace function is added to escape single quotes. If you don't have that and there is a single quote in the combobox value you will get syntax errors.
 

Users who are viewing this thread

Back
Top Bottom