Close form without saving/creating a record

loopa1

Board Regular
Joined
Sep 3, 2006
Messages
156
Hi all
I have a form which when opened it automatically completes a field and therefore creates a new record.

However, If no other fields are entered in to, I want the user to be able to close the form and for the record to be 'ignored' so that tne next time a record is created, it uses this records ID - is this possible?


Thanks.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
A new record shouldn't be created when something is entered in a field, even if you do it automatically with code.

It new record will be created when you close the form as that will update the data source.

You should be able to stop a new record being created on close by checking the other fields.
 
Upvote 0
I'm not sure what you mean by 'You should be able to stop a new record being created on close by checking the other fields'.

Because the ClientID is populated automatically (which then inserts the client's name too), a new EpisodeID (primary key - autonumber) is created too.

So When I DoCmd.Close the form, the record is kept in the table linked to the form.

Instead, I'd like the user to be able to choose to either ignore the data they've inserted, or if they haven't entered any data, the record isn't kept in the table and the next time an Episode is added, it uses the lowest possible autonumber instead of incrementing it all the time.
 
Upvote 0
What I'm trying to say is that a new record is not created until you close the form.

It's not created when you enter data on the form.

You can see that if you enter data on a form and before you close it open the record source of the form.

The 'new' record won't be there.

Now close both and re-open the record source.

The new record will be there.
 
Upvote 0
Scrap that...I've managed to sort that.

But...it's still incrementing the autonumber, is there a way I can prevent this? It's not a big issue, but I'd just prefer it if my ID's were kept as sequential as possible.
 
Upvote 0
Having read a few posts on the web, it seems you can't do what I want to do with an Autonumber - instead, I'll need to use the autonumber as the field to uniquely represent that record and create my own number field for the 'viewable' record ID which I can make sure is sequential with DMax(....

Thanks.
 
Upvote 0

Forum statistics

Threads
1,224,589
Messages
6,179,744
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top