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

Why can't I save a record using this attached code?

Status
Not open for further replies.

Cleis

Technical User
Jun 4, 2000
197
US
Hi Group:

Can someone tell me why I can't save a record using this code? I'm getting an error message saying that Access can't go to the last record; it's already at the end of the recordset?

Thanks

Rich
Chicago

Private Sub CmdAdd_Click()

DoCmd.GoToRecord , , acNewRec


If Response = vbYes Then

MyString = "Yes"
Me.RecordsetClone.AddNew
Call Enable
' goes to a function that checks if fields are filled in

Private Function Verify()

'



[tblNotes.Vendor#] = [Vendor#]
[tblNotes1.Vendor#] = [Vendor#]

Me.RecordsetClone.Update
Me.Bookmark = Me.RecordsetClone.LastModified

'Does a few other things.....

End Function


 
You may need to leave off the 'DoCmd.GoToRecord , , acNewRec' since you are creating a new rec with the clone?
 
While ago I had a similar problem. Turned out I was asking it to add a second record with the same key.
Tom Budlong
TomBudlong@Bigfoot.com

 
If you use Docmd.gotorecord , , acLastrec instead it will go to your last record, which may or may not be empty. If its not empty then you can safely add a new record, and if your key fields are empty then you can use the record as the new one.

One thing to remember when automating new records:

New records are only new records when you put some data in them, if you create a new record, do nothing, then goto another record or close, the new record is not saved.


Andrew.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top