473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Methods to undo changes on subforms

Hello,

I have a form with a subform and another subform inside the first subform. I know that if the user types in a value on one of the subforms, the data is autmatically committed (Autosaved) to the table which is bounded to the subform/textbox. When the user closes the main form a message prompts with "Save YES or NO?". If he selects NO I want the mainform to close without saving the records.

As far as I know there are two options:

1. Create a Unbound Form

This involves a lot of VBA programming and the use of INSERT INTO SQL statements to set values to each table.

2. Run a DELETE SQL statement

I can delete the record after it is committed. However the Primary Key ID will still be incremented. I don't know if there is a maximum value for Primary Key?


What option do you guys advise, or are there several other options?
Nov 20 '14 #1

✓ answered by jforbes

You have a pretty good handle on your situation. The max number for an AutoNumber is in the range of 2 Billion. I guess technically 4 Billion if negative numbers are included. I would run the Delete.

There might be a third option:
Create a Form with the View set to Single Form. Make it bound to the Sub Table. Then open it from your SubForm in acDialog and acFormAdd (Add only mode for inserting a record). If I remember right, you are keeping a history, so you wouldn't need to edit, but you could do that also with a separate button. You could use the MainForm and SubForm's current record to default the Fields on the Dialog Form. And use the AfterUpdate and AfterInsert to perform any linking code after the record is added/changed.

2 1878
jforbes
1,107 Expert 1GB
You have a pretty good handle on your situation. The max number for an AutoNumber is in the range of 2 Billion. I guess technically 4 Billion if negative numbers are included. I would run the Delete.

There might be a third option:
Create a Form with the View set to Single Form. Make it bound to the Sub Table. Then open it from your SubForm in acDialog and acFormAdd (Add only mode for inserting a record). If I remember right, you are keeping a history, so you wouldn't need to edit, but you could do that also with a separate button. You could use the MainForm and SubForm's current record to default the Fields on the Dialog Form. And use the AfterUpdate and AfterInsert to perform any linking code after the record is added/changed.
Nov 20 '14 #2
Thnx, the Delete method works fast and simple.
Still have 2,147,483,647 records to go :P
Nov 24 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: Darryl Kerkeslager | last post by:
I don't do much with subforms - in fact I've deliberately avoided them - but .... I have a tab control that will contain several subforms, each bound to a separate table, and each table/subform...
6
by: Raji16 | last post by:
Hi, I am a new member. i am designing a simple judicial database system. however after creating tables i am a bit confused on setting the relationships between tables :confused: here is the link...
4
by: microb0x | last post by:
I have an application with a master form with a tab control containing nine tabs, each tab contains a subform. I have command buttons on my main form including: Save , Cancel , Close. My...
4
by: Birky | last post by:
I’m hoping you can help me get my form to work. I have a few issues that I need to get squared away. 1. I am using a form for data entry only therefore I need the form to pop with the next...
1
by: inadsad | last post by:
Greetings Group: I got a form with multiple controls that are bound to a dataset, with two buttons & next/previous. Simply, add button adds a new record and cancel button undo changes. On add...
2
by: antmail | last post by:
Hi Guys, Been using this forum to get my answer for quite a while now, but finaly I am stumped. I have a form with a subform. I control on the main form when the data is saved and when it is...
1
imrosie
by: imrosie | last post by:
Hello experts, I have 3 cmd buttons (undo changes, clear order and save order). I added a second subform and moved some controls around...Now I'm having difficulty getting them to work again on...
3
imrosie
by: imrosie | last post by:
Hello anyone, Is there someone that has a routine to do this? On the Main form I have cmd buttons that clear and undo.. Specifically the Undo doesn't undo the subforms, just the Main form. I...
2
by: yedidel | last post by:
Hello, I have a form that edits an Order. Each order has several OrderItems which are edited by a continous-form subform inside the main form. Each OrderItem also has several OrderItemsAdditions...
1
by: rahul2310 | last post by:
I have form in which i do not want user to cancel or undo changes made in form so i removed cancel button but i found out user can press escape and undo it Is it possible to stop user from undo the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.