By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,956 Members | 1,683 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,956 IT Pros & Developers. It's quick & easy.

Programmatically saving a record

P: n/a
Afternoon everyone,

The Non Conformance file used as part of "my" companies GMP compliance
program uses a form that saves a record as per the code below ...

stDocName = "NCF Form"
DoCmd.OpenForm stDocName, acNormal, , , acFormAdd
Forms![NCF Form]![NCR] = DDate & "-" & Format(NCRNumber, "0000")
Forms![NCF Form]![Date Initiated] = Date
DoCmd.RunCommand acCmdSaveRecord
Forms![NCF Form]![Type].SetFocus

The idea of the form is the the new NCF number is automatically
generated, along with the Date of entry and then the form is saved to
stop duplicate NCF numbers being allocated. If the record is saved,
can anyone pls tell me why duplicate numbers are being allocated? I
should also add that there is code to delete any record that has had
data enetered if a user does not actually enter anything when the form
is closed. Do I need to change the code to force people to enter data
before the record is saved?

Suggestions are welcome.

Stinky Pete ;-)

Mar 12 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Stinky Pete wrote:
Afternoon everyone,

The Non Conformance file used as part of "my" companies GMP compliance
program uses a form that saves a record as per the code below ...

stDocName = "NCF Form"
DoCmd.OpenForm stDocName, acNormal, , , acFormAdd
Forms![NCF Form]![NCR] = DDate & "-" & Format(NCRNumber, "0000")
Forms![NCF Form]![Date Initiated] = Date
DoCmd.RunCommand acCmdSaveRecord
Forms![NCF Form]![Type].SetFocus

The idea of the form is the the new NCF number is automatically
generated, along with the Date of entry and then the form is saved to
stop duplicate NCF numbers being allocated. If the record is saved,
can anyone pls tell me why duplicate numbers are being allocated? I
should also add that there is code to delete any record that has had
data enetered if a user does not actually enter anything when the form
is closed. Do I need to change the code to force people to enter data
before the record is saved?

Suggestions are welcome.

Stinky Pete ;-)
Nothing you posted describes where NCRNumber comes from. If that is what is
being duplicated then the process that generates new NCRNumbers is where you
need to be looking.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Mar 12 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.