Form to add new record with autonumber key

  • Thread starter Thread starter David
  • Start date Start date
D

David

I am completely redesigning a system.
The main table originally had a key with a programatically
assigned sequence number. I have replaced this with an
autonumber key.
There is a tabbed form to add new records. This form is
accessed from a selection list by either clicking an
existing record or clicking a 'NEW' button.

It uses the following statements when loading the form to
create/edit the record:

Set recRecordset = Forms!frmISRDetail.RecordsetClone

If Forms!frmISRDetail.OpenArgs = "New" Then
DoCmd.GoToRecord , , A_NEWREC
txtRequestNum = NextRecordID
Else
strCriteria = "ChangeRequest.ID = " & Forms!
frmISRSelection.lstISRList
recRecordset.FindFirst strCriteria
Forms!frmISRDetail.Bookmark = recRecordset.Bookmark

My problem is that this logic no longer works with the
autonumber key. I get an error on the 'GoToRecord'
statement saying it cannot go to that record. How would I
code this to open up the form to add a new record (with an
autonumber key)?
Thanks for any help you can provide.
- David
 
Your code looks fine. The problem is the A_NEWREC you are using. Did you
define your own constant? The standard constant for the new record is
acNewRec.

Kelvin
 
Back
Top