Unwanted New Record

schumarg

Registered User.
Local time
Today, 14:31
Joined
May 13, 2003
Messages
94
Hi,

Been searching through the forum and can't seem to locate a solution, for what I'm assuming is simple but .......

I have a form that is set to DataEntry, I enter all the data and upon completing the last entry/tab a new record appears. This is fine if I want to complete a new record. However, if I do not want a new record and want to simply close the form, I end up with a new empty record. I tried adding a delete code along with the close cmd, but it deletes the new record and when the form closes it creates a new empty record again.

What I would like to accomplish is to close the form with it accepting what I just entered and not create a new blank record.

Thanks in advance,
Bob
 
Do you have some event in your form's code that plugs in a value to a record?
 
Hi,

Not intentionally, do have the OrderNum field datatype set as AutoNumber. As to the other fields, they're just Text or Date/Time datatypes.

I did some more searching and found the Cycle/Set to Current and tried it. Seems to work, not sure this is the proper way of doing it, but........

Thanks,
Bob
 
The Cycle record property will keep the form from scrolling to a new empty record but your code behind the form is what was causing the problem. If you are placing values in fields, you should do it in the BeforeInsert event. That event is only fired for new records but it is not fired until the user dirties the record. So just scrolling to a new record won't dirty the record which is the problem with your current code.

Even though the Cycle record property fixed the symptom, I suggest actually fixing the code.
 
Hi,

I'm not sure about the cycle record property, but this thread is along the lines of what I'm looking for.

I have a form, and a subform within a subform.

When I click on the last record button on the main form and then click the next record button, it goes to the Autonumber field, as it's supposed to. But, I wish to stop all the forms from scrolling on the last data record.

Now I will mention that the main form has an autonumber primary key. Same with the subform. But, the subform inside the subform is not an autonumber field, though it too is primary. I just don't want to change it since 'everything' works.

Any help?

Thanks,
Jim
 
You have two choices.
1. Create custom navigation buttons with code behind them. You can then customize the forward button when the form is sitting on the "last" record to prevent forward scrolling.
2. Change the form properties to AllowAdditions = No. You will then need to add a NewRecord button to each form to allow new records to be added.
 

Users who are viewing this thread

Back
Top Bottom