Goto Record Combo Box Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a combo box that should goto a record on the form based on the
selected value in the combo box.

Right now all you get is type mismatch error.

Here is the code in the combo box.

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[UserID] = " & Str(Nz(Me![Combo101], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

Refresh

TIA,
Tim J
 
If UserID is Numeric then take out the conversion to string
rs.FindFirst "[UserID] = " & Nz(Me![Combo101], 0)

if UserID is Text then surround with single apostrophes
rs.FindFirst "[UserID] = '" & Str(Nz(Me![Combo101], 0)) & "'"
 
I am still getting a type mismatch error

the value is a name and I have enclosed in single quotes, still the same error

any Ideas?

Dennis said:
If UserID is Numeric then take out the conversion to string
rs.FindFirst "[UserID] = " & Nz(Me![Combo101], 0)

if UserID is Text then surround with single apostrophes
rs.FindFirst "[UserID] = '" & Str(Nz(Me![Combo101], 0)) & "'"
Tim J said:
I have a combo box that should goto a record on the form based on the
selected value in the combo box.

Right now all you get is type mismatch error.

Here is the code in the combo box.

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[UserID] = " & Str(Nz(Me![Combo101], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

Refresh

TIA,
Tim J
 
I have just tried it myself, the problem is the str & Nz.
Change it to this instead & it works OK
rs.FindFirst "[UserID] = '" & Nz(Me![Combo101], "") & "'"


Tim J said:
I am still getting a type mismatch error

the value is a name and I have enclosed in single quotes, still the same error

any Ideas?

Dennis said:
If UserID is Numeric then take out the conversion to string
rs.FindFirst "[UserID] = " & Nz(Me![Combo101], 0)

if UserID is Text then surround with single apostrophes
rs.FindFirst "[UserID] = '" & Str(Nz(Me![Combo101], 0)) & "'"
Tim J said:
I have a combo box that should goto a record on the form based on the
selected value in the combo box.

Right now all you get is type mismatch error.

Here is the code in the combo box.

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[UserID] = " & Str(Nz(Me![Combo101], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

Refresh

TIA,
Tim J
 
Back
Top