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

My code doen't work but used to... 1

Status
Not open for further replies.

mrgrogro

Technical User
Jan 8, 2005
58
0
0
US
I'm using the following code (provided to me long ago on this site...thanks!) and have used it many times to search one form from another pop-up form.

Private Sub Enter_Code_AfterUpdate()

Dim db As DAO.Database, rst As DAO.Recordset
Dim frm As Form, Criteria As String

Set db = CurrentDb()
Set frm = Forms![Film Transfers Data Entry]
Set rst = frm.RecordsetClone

Criteria = "
Code:
='" & Me![Enter Code] & "'"
   rst.FindFirst Criteria
   
   frm.Bookmark = rst.Bookmark
   
   Set rst = Nothing
   Set frm = Nothing
   Set db = Nothing
DoCmd.Close

End Sub

I have other databases that I've compared it to and can't find the problem.  In this case, the form to search is "Film Transfers Data Entry", the information I am seeking is "Code" and the field I'm using in my search form is called "Enter Code".  I know the record exists for which I am searching but each time get a response "Run time Error '3021', No Current Record".  When I debug, the line highlighted is "frm.Bookmark = rst.Bookmark".  I dont think the problem is the code.  I think the problem is a database setting itself.  Any help would be greatly appreciated!
 
Check out rst.NoMatch, rst.EOF and rst.BOF after you issue the "FindFirst" command. The message usually means that you are at EOF or BOF on the recordset.

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Thanks Golom. I was trying to do something stupid. Your ideas got me to thinking. I was trying to search with the database in edit mode. I had never tried that before and didn't know it couldn't be done. Thanks again!

mrgrogro
 
was trying to search with the database in edit mode"

What does the above statement mean? what is "edit mode"??
 
James529

A recordset is in Edit mode when you use the rs.Edit method but have not yet issued an rs.Update or rs.CancelUpdate command.

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top