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

Error message when trying to use combo box 1

Status
Not open for further replies.

learnasugo

Programmer
May 10, 2004
38
US
I am using Access VBA code and trying to select a record from an unbound combo box and I keep getting an error message that says "No current record" Does anyone know what that means? Here is the code.

Private Sub Combo58_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[MMSJob] = '" & Me![Combo58] & "'"
Me.Bookmark = rs.Bookmark
End Sub

Thank you

learnasugo

 
Hi!

The message means that the recordset is at the "end of file" (EOF), thus "there is no current record", meaning the .FindFirst didn't find a record matching your criteria.

To avoid it, try using a test for either .Nomatch or .Eof before assigning the bookmark.

[tt]if not rs.nomatch then me.bookmark=rs.bookmark[/tt]

But - I'm thinking that you perhaps should have the record available, then perhaps have a look at some of the form properties - the DataEntry should probably be no, AllowAdditions, AllowEdits Yes (or if you're opening it thru the openform method of the docmd object, don't use the acFormAdd arguement). Could perhaps also be that the form recordset is using another filter/criteria than the combo, but the above suggestion (.NoMatch) should prevent that, perhaps also add a message "no record found..." if that's the case.

There are also some "pure" access fora, take a look at the "Related Forums" box at the right, where some of them are listed.

Roy-Vidar
 
You are a dream!!! Thank you so much !!! Would you believe that all of this agony was because I had the DataEntry turned to yes. Almost a week of pulling my hair out and migranes for one click of a button.

Thank you SOOOOO much!!!! [bigsmile] [flip]

learnasugo [spin2] [spin]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top