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

Searching for records with Combo Box

Status
Not open for further replies.

jasonmac

Programmer
Nov 14, 2002
175
US
Hi everyone. I'm running into something here that hasn't seem to happen before. I'm using a combo box called cboFind to let the user select which record he/she wants to work with. Here is the code.

"Private Sub cboFind_AfterUpdate()
Dim R As Recordset
Set R = Me.RecordsetClone

** R.FindFirst "[RFQNumber] = '" & Me![cboFind] & "'"

Me.Bookmark = R.Bookmark

Me![cboFind] = Null

End Sub"

The line with the ** is where Access takes me when I select debug. The error is as follows:

"Object is invalid or no longer set."

Does anyone know what causes this. It seems to work fine once or twice but then errors out. The RFQNumbers field is a text field.

Thanks in Advance,
Jason
 
The code when the wizard creates the find record from a combo box is below. Maybe it has to do with the quotes or setting it to Null. The wizard also sets R as an object, not a recordset, but that shouldn't matter.

Set r = Me.Recordset.Clone
r.FindFirst "[RFQNumber] = " & Str(Me![cboFind])
Me.Bookmark = r.Bookmark



DreamerZ
simplesolutions@prodigy.net
[ignore][/ignore]
 
Jasonmac, you need to Dim your R as an Object instead of Recordset. The following works for me all the time.

Private Sub FindDwg_AfterUpdate()
' Find the record that matches the control.
Dim RS As Object

Set RS = Me.Recordset.Clone
RS.FindFirst "[DwgNum] = '" & Me![FindDwg] & "'"
Me.Bookmark = RS.Bookmark
End Sub

HTH
Dave
 
Sorry DreamerZ, I missed where you told him about setting the R as object. That's what I get for reading too fast.

Dave %-) :~/
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top