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

Run-time error 3021 problem

Status
Not open for further replies.

KerryL

Technical User
May 7, 2001
545
US
On a form I use to add items to the product table there are two combo boxes:
cboDivision is used to select the division,
cboDescription is used to select the item (description).
(cboDescription is limited by what is first chosen in cboDivision).

When the description is chosen, other text fields on the form are populated with the product information and can then be edited. However, I'm suddenly receiving the following error message:

Run-time error '3021':
No current record.


The debugger highlights the >line of code< below:

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

Set rs = Me.Recordset.Clone
rs.FindFirst &quot;[ID] = &quot; & Str(Me![cboDescription])
>Me.Bookmark = rs.Bookmark<
End Sub

Private Sub cboDivision_AfterUpdate()
Me.cboDescription.Requery
End Sub
/code


I don't recall making any changes before this began to occur, and I can't find anything in Access help or on Microsoft's Knowledge Base on error 3021. Can someone help me understand why the control can't find the corresponding record when cboDescription is selected?

Thanks very much in advance,
KerryL
 
Set rs = Me.RecordsetClone

(.RecordsetClone without point)

Aivars [pipe]
 
Thanks Aivars,

I gave it a try--removed the dot between Recordset & Clone but I'm getting the same error message. Then the debugger points me at this line:

Me.Bookmark = rs.Bookmark


Could it have something to do with how the row source for the two cbo's are set up? Or whether the key field in the table is tied to each of the cbo's?

I can't even add a new cbo and get it to work now, and it was working fine yesterday. Frustrating.

KerryL
 
Run-time error '3021':
No current record.
What would cause not having a current record at the point the error is displayed?

If you didn't find a record.
rs.FindFirst &quot;[ID] = &quot; & Str(Me![cboDescription])

Put a display here to check what is in rs. Make sure you have a record at this point.
debug.print &quot;rs eof = &quot; rs.EOF
debug.print &quot;rs bof = &quot; rs.BOF
 
if not rs.eof then
rs.FindFirst &quot;[ID] = &quot; & Str(Me![cboDescription])
if not rs.nomatch then
Me.Bookmark = rs.Bookmark
else
msgbox &quot;There is not found ...&quot;
end if
else
msgbox &quot;There is not any record...&quot;
end if

Aivars
 
I figured out why I started receiving this error message all of a sudden. It's actually kind of embarrassing, so I apologize for making you go to all the trouble of trying to help me out.

When I created the form and opened it in regular view it worked just fine. But I started having problems after adding it to one of the switchboard menus as a selection. Turns out I set it to open in &quot;add&quot; mode instead of &quot;edit&quot; mode. After changing it, the form is working just fine. DUH!

Again, my apologies for the time you spent trying to help me out due to the fact that I didn't catch my mistake sooner. Thank you very much for your assistance.

KerryL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top