473,396 Members | 1,756 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,396 software developers and data experts.

how to undo data on a parent form

I've got two forms called cashtransactions and cashtrndetail.

I have created a code that when the cashtransactions form open, it fills in data and then it also creates an autonumber in the one field.

On the subform cashtrndetail I have command buttons. The one is a close button. I am trying to write a code that if data was entered in any of the field in the subfrom and when I click the close command button then a msgbox appears saying that the details will be discarded and am I sure I want to close the form.

When I say yes to discard the details I want to undo all the data on the parent form and the subform and then close the form.

Can anyone please help!!!

Thanks
Ryno
May 26 '11 #1
2 1831
TheSmileyCoder
2,322 Expert Mod 2GB
As soon as you move focus to the subform, the parent form is saved. And if you have more then 1 record in your subform, the same goes when you move between them.

This means that technically you will not be able to do a undo, but have to delete your records instead.

Other option could be to use unbound forms, or bind both forms to temporary tables, and have some code in the unload event of the main form, in which you either transfer the new records to the main tables, or discard them.
May 27 '11 #2
Adam Tippelt
137 100+
One thing to add to Smiley's idea of temporary tables is you'll still find that switching between parent form and subform will still save the record, even if it is saving it to the temporary tables instead.
One way to get around this is to have two global boolean variables, one that handles changes on the parent form, and one that handles change on the subform. So whenever a field on the parent form is edited, you tell it to set the first boolean variable to true. Whenever a field on the subform is edited, you tell it to set the second boolean variable to true.

When you come to checking if something needs saving, you can do a simple check to see if either of these are true, and ask whether the user wants to 'save' or not.

Expand|Select|Wrap|Line Numbers
  1. if (GMainChanges = True) or (GSubChanges = True) then
    <<<<YOUR CODE>>>> 
    'Set variables to false after you've finished.
    GMainChanges = False 
    GSubChanges = False
    else
    'Delete temporary records.
    end if
One variable is needed for each, because just as the main form is saved when you enter the subform, the subform is then saved when you leave it and enter the main form.

Adam.
Jun 9 '11 #3

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

Similar topics

2
by: Iain Miller | last post by:
Struggling a bit here & would be grateful for any help. I have a table which has a list of people in it. Each person has a unique ID automatically allocated by Access but also belongs to one of 5...
1
by: Alex Wisnoski | last post by:
Access 97SR2-I am trying to create a Job Position data entry form based on a table. The form has 15 fields on it. I want to use a combo box to look in the table and see if the position number...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
1
by: Alex.Wisnoski | last post by:
I have a data entry form with a combo box to look up an entrant's name. If the name is already in the table then it pulls up the record and that part of the form works fine. If the name isn't in...
2
by: filbennett | last post by:
Hi Everyone, I'm generally unfamiliar with Access form design, but have programmed Cold Fusion applications for a couple of years. I'd like to build a data entry form in Access that allows the...
3
by: =?Utf-8?B?aWxy?= | last post by:
Hi All I am developing an vb 2005 winforms application that connects to a database and displays a datagridview of the data. A user can select and then edit, or create a new entry by opening a...
13
by: bitsnbytes64 | last post by:
Hi, I have a form which contains a subform. Both are were creetd using the form wizard and are bound by the column IXO_NR (on two different tables), which is the control source for a textbox on...
4
by: =?Utf-8?B?RWl0YW4=?= | last post by:
Hello, I developed a Composite Control with Visual C# (Rocker Button). The button detects MouseUp events inside the control. However I would like these MouseUp events to be transferred to the...
7
by: John Crozier | last post by:
Hello! I would like to retreive data from an array in a parent form. I think it's best explained by showing an example... Parent Form Option Compare Database Dim ChildNum(1 To 255) As Integer...
0
by: sudhirb | last post by:
Hello I am using MS Access 2003. I have a parent form based on parent table which contains unique ID field( primary key) which i enter first on the parent form. Parent table also contains fields...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.