Combo box in Access Data Project

G

Guest

Could someone help me with a combo box that I'm using to search for a record.
Here is the code that I used in Access before I up sized.

Thanks Jerry

Private Sub Combo10_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.findFirst "[TenantID] = " & Str(Me![Combo10])
Me.Bookmark = rs.Bookmark

End Sub
 
G

Guest

Is the TenantID is string type? if so then you should change this line
rs.findFirst "[TenantID] = " & Str(Me![Combo10])
To
rs.findFirst "[TenantID] = '" & Str(Me![Combo10]) & "'"

If TenantID is number type then you should drop the str
rs.findFirst "[TenantID] = " & Me![Combo10]
 
S

Sylvain Lafontaine

If I remember correctly, there is no FindFirst method with the ADO
Recordset. You should use something like:

With Me.RecordsetClone
.Find "[TenantID]=" & Me!Combo10

If (.BOF Or .EOF) Then
.movefist
If (.BOF Or .EOF) Then Exit Sub ' In case of an empty
recordset.
End If

Me.bookmark = .bookmark
End With

Also, instead of « Dim rs As Object », you should use « Dim rs As
ADODB.Recordset »; otherwise you will often mix DAO with ADO code.
 
G

Guest

The TenantID is a number and I'm getting a 438 error. I tried it both ways
and it still doesn't work

Ofer said:
Is the TenantID is string type? if so then you should change this line
rs.findFirst "[TenantID] = " & Str(Me![Combo10])
To
rs.findFirst "[TenantID] = '" & Str(Me![Combo10]) & "'"

If TenantID is number type then you should drop the str
rs.findFirst "[TenantID] = " & Me![Combo10]


--
In God We Trust - Everything Else We Test


Jerry said:
Could someone help me with a combo box that I'm using to search for a record.
Here is the code that I used in Access before I up sized.

Thanks Jerry

Private Sub Combo10_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.findFirst "[TenantID] = " & Str(Me![Combo10])
Me.Bookmark = rs.Bookmark

End Sub
 
G

Guest

Thanks
That worked great

Sylvain Lafontaine said:
If I remember correctly, there is no FindFirst method with the ADO
Recordset. You should use something like:

With Me.RecordsetClone
.Find "[TenantID]=" & Me!Combo10

If (.BOF Or .EOF) Then
.movefist
If (.BOF Or .EOF) Then Exit Sub ' In case of an empty
recordset.
End If

Me.bookmark = .bookmark
End With

Also, instead of « Dim rs As Object », you should use « Dim rs As
ADODB.Recordset »; otherwise you will often mix DAO with ADO code.

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF


Jerry said:
Could someone help me with a combo box that I'm using to search for a
record.
Here is the code that I used in Access before I up sized.

Thanks Jerry

Private Sub Combo10_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.findFirst "[TenantID] = " & Str(Me![Combo10])
Me.Bookmark = rs.Bookmark

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top