Why "no current record?"

L

LAS

Me.Recordset.AddNew
Me.Recordset.Edit 'I GET A NO CURRENT RECORD ERROR AT THIS POINT - HOW
COME????
Me!Student_ID = cboStudent_ID

This form was working fine until I discovered that it was creating rows with
missing data. I didn't want a row created until certain data was entered,
so I moved the assignments earlier. Now I'm getting this.

What am I doing wrong besides trying to manage my form outside of "the
Access way?" Can someone just addres the coding issues here, rather than
the decision to try to use code?

TIA
LAS
 
B

Bob Quintal

Me.Recordset.AddNew
Me.Recordset.Edit 'I GET A NO CURRENT RECORD ERROR AT THIS
POINT - HOW
COME????
Me!Student_ID = cboStudent_ID

This form was working fine until I discovered that it was creating
rows with missing data. I didn't want a row created until certain
data was entered, so I moved the assignments earlier. Now I'm
getting this.

What am I doing wrong besides trying to manage my form outside of
"the Access way?" Can someone just addres the coding issues here,
rather than the decision to try to use code?

TIA
LAS
What you are doing is confusing Access. First you tell Access to add a
new record, which clears certain pointers in the recordset, then,
before you have entered any data and saved the record you tell Access
to edit the current record, which does not yet exist.

Just remove the Me.Recordset.Edit line and your code will work.
 
L

LAS

Thanks. I think I knew that once... :)

Bob Quintal said:
What you are doing is confusing Access. First you tell Access to add a
new record, which clears certain pointers in the recordset, then,
before you have entered any data and saved the record you tell Access
to edit the current record, which does not yet exist.

Just remove the Me.Recordset.Edit line and your code will work.
 
D

David W. Fenton

Me.Recordset.AddNew
Me.Recordset.Edit 'I GET A NO CURRENT RECORD ERROR AT THIS
POINT - HOW
COME????
Me!Student_ID = cboStudent_ID

You're mixing recordset and form editing. The .AddNew creates a new
record in the form's underlying recordset and displays it in the
form's display and edit buffers. You aren't editing the recordset,
since you're using the form's edit buffer, not the form's recordset,
to assign the value. Thus, you don't need the .Edit, as you aren't
editing the recordset in the first place.

Again, I keep telling you this -- just stop using the form's
recordset and you'll avoid all these kinds of problems. You're
trying to work with data in the form the way you work with data in a
recordset in code, and this is antithetical to the whole point of
bound Access forms.
 
D

David W. Fenton

OK, to "stop working with the form's recordset," can I just change
the statements here???

Well, you're using the recordset to create a new record. Instead,
you could use:

DoCmd.GoToRecord acForm, "MyForm", acNewRec

You don't need the Me.Recordset.Edit even if you're using the
recordset to add the new record, so all you really have to do is
remove the .Edit and it should work.
 

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