Christine Pearc
Christine
- Local time
- Today, 17:10
- Joined
- May 13, 2004
- Messages
- 111
I can't for my life figure out how to prevent adding a record to a table when the user decides they don't want to add the record, or when they "save" the record but then decide they want to delete it. (Yes, our company has a lot of finicky and confused people.) Problem is, Access automatically adds a record after you've entered something in a field. I've been in a lot of forums looking for answers but the answers are either over my head (theory or incomplete) or not quite what I need. PLEASE can someone help me, a complete novice?
Here's a bit of background.
The application will be used by many people and will reside on our server.
The Main Menu has a button "Add New", with the following command:
DoCmd.OpenForm "Create CAR frm", acNormal, , , acFormAdd, , 1
The Create CAR frm opens to allow the addition of one new record. The form's record source is tblCARs. Control sources for all the fields on the form are set to fields in tblCARs. (I think this means they are "bound"). One of the fields, CARNum, is currently set to be an AutoNumber.
I want this AutoNumber to increment only when the user presses the SAVE button, and the rest of record to be saved only when SAVE is pressed.
If the user presses the CANCEL button, then nothing is saved to tblCARs.
If DELETE is pressed (which becomes active only after SAVE has been pressed), then the record should be deleted.
A very nice Microsoft MVP at the Access community newsgroup offered the following suggestion:
Create another table to hold the highest CARNum assigned so far. Then in the BeforeUpdate event procedure of the form where a new record is added:
a) Open a recordset into this number table, locking it exclusively.
b) Increment the number and hold the lock on the table.
c) Assign the new number ot the record in your form, and save the form.
d) Once the new record has saved, release the lock on the number table.
e) Incorporate error handling that involves random delays and a fixed number of retries to handle the case where multiple users try to append records at the same time.
Unfortunately, I do not think he has the time to help me actually figure out how to do all of this. I've read all the Help info and searched the newsgroup for recordsets, etc. but still can't figure out what to do/what to write in the code.
I need alot of hand-holding for this. Could someone here take me under their wing?
Thank you,
Christine
Here's a bit of background.
The application will be used by many people and will reside on our server.
The Main Menu has a button "Add New", with the following command:
DoCmd.OpenForm "Create CAR frm", acNormal, , , acFormAdd, , 1
The Create CAR frm opens to allow the addition of one new record. The form's record source is tblCARs. Control sources for all the fields on the form are set to fields in tblCARs. (I think this means they are "bound"). One of the fields, CARNum, is currently set to be an AutoNumber.
I want this AutoNumber to increment only when the user presses the SAVE button, and the rest of record to be saved only when SAVE is pressed.
If the user presses the CANCEL button, then nothing is saved to tblCARs.
If DELETE is pressed (which becomes active only after SAVE has been pressed), then the record should be deleted.
A very nice Microsoft MVP at the Access community newsgroup offered the following suggestion:
Create another table to hold the highest CARNum assigned so far. Then in the BeforeUpdate event procedure of the form where a new record is added:
a) Open a recordset into this number table, locking it exclusively.
b) Increment the number and hold the lock on the table.
c) Assign the new number ot the record in your form, and save the form.
d) Once the new record has saved, release the lock on the number table.
e) Incorporate error handling that involves random delays and a fixed number of retries to handle the case where multiple users try to append records at the same time.
Unfortunately, I do not think he has the time to help me actually figure out how to do all of this. I've read all the Help info and searched the newsgroup for recordsets, etc. but still can't figure out what to do/what to write in the code.
I need alot of hand-holding for this. Could someone here take me under their wing?
Thank you,
Christine