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

How to stop subforms from autosaving upon losing focus?

I have a Main form with several tabs. Each tab contains subforms that hold various employee information regarding benefits, dependant coverage, retirement, etc. I have a Save and cancel function on the form. I wish to edit information on these tabs regarding employee information and wait until save is clicked to save all information. If the user selects cancel I'd like it to cancel all changes made to all subform and form fields. However the subforms are saving changes automatically and when I attempt a Cancel = true in the before_update event it refuses to allow that subform to lose focus until the chgs are saved. I can populate the fields programatically and force updates and cancels but...some of the subforms are datagrids for 1 to many relationships and variable arrays have to be declared with constant expressions. I would appreciate any suggestions on this.

Thanks, Keriana
Nov 30 '07 #1
5 6392
puppydogbuddy
1,923 Expert 1GB
I have a Main form with several tabs. Each tab contains subforms that hold various employee information regarding benefits, dependant coverage, retirement, etc. I have a Save and cancel function on the form. I wish to edit information on these tabs regarding employee information and wait until save is clicked to save all information. If the user selects cancel I'd like it to cancel all changes made to all subform and form fields. However the subforms are saving changes automatically and when I attempt a Cancel = true in the before_update event it refuses to allow that subform to lose focus until the chgs are saved. I can populate the fields programatically and force updates and cancels but...some of the subforms are datagrids for 1 to many relationships and variable arrays have to be declared with constant expressions. I would appreciate any suggestions on this.

Thanks, Keriana
put the following code after the cancel = true statement and see if it helps. If not, then you need to post your code.

Expand|Select|Wrap|Line Numbers
  1. If Me.Dirty = True
  2.   Me.Undo
  3. End If
Nov 30 '07 #2
NeoPa
32,556 Expert Mod 16PB
I guess from the
...some of the subforms are datagrids for 1 to many relationships...
bit that the recordsource for all the subforms cannot be simply the same. In which case then, Access will not be able to manage this as you envisage it. Each form is only active when it has the focus and will either update or cancel (lose changes) when focus is lost.
pDog has already indicated the code you need if you want to move on and lose any changes.
How reasonable it is to expect Access to maintain links to various recordsets (many of which are inter-dependant) is another matter.
I imagine that this could be done (but with great difficulty and having to recode many of the built-in features of Access) but I doubt it's worth the effort. It would essentially be coding around Access rather than coding within it, which should be avoided where possible.
Nov 30 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
The only way to handle subforms in this manner is to use PuppyDogBuddy's me.dirty routine on all the subforms. Of course you would have to refer to the subform.

Me.subformobjectname.Form.Dirty

However, you will have a problem with the datagrids if you changed anything other than the current record. If you move off the current record then any changes will be saved.

My advice is to have a save and cancel button on each of the subforms. This will at least allow you to control the current record.

Mary
Nov 30 '07 #4
Yeah. I would much rather be using something like VB unfortunately it is not an option at work. The idea was to make changes to any of their information and save one time but I cannot do from one recordsource because of the one to many relationships. There everything from Retirement info, to benefit info, dependants info carried on coverage, Disability, etc. No way to use 1 recordsource and requires me to make chgs in like 10 diff forms.

Thanks for the feedback though.
Dec 1 '07 #5
Solved my own problem. At least so far. The only way to allow a main save and cancel function with subforms that use different recordsources is to programatically define the recordset based on query. Circle thru the recordset when you press Edit and use ReDim to define dynamic variable array and store the "old values" in variables. Then if user presses cancel, you can circle thru the recordset and reassign those old values. Its alot of work but so far it has the desired effect.
Dec 3 '07 #6

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

Similar topics

0
by: Stefan De Schepper | last post by:
Dear NG, I created a gridlike usercontrol. When clicking on a cell a textbox (or other control, depending on the cell's editortype) is shown. When some other control gets the focus, the textbox...
3
by: Chris | last post by:
I have a form that calls ShowDialog on a number of different forms at different times. I want to be able to know anytime the form loses focus. But Form.Focused isn't ever true once a control has...
4
by: Elaine | last post by:
Hi I have created a form which contains a subform. To cut a long story short, I have created a macro that moves the focus to the subform (GoToControl) and sets a value (SetValue) in the field...
6
by: DrifterKona | last post by:
I have a form with 4 pages. I'm not sure of the correct name, but I will refer to the tabs at the top of the form that list the names of the four pages as the "page tabs". When the form opens,...
2
by: robert.waters | last post by:
Hello, If I have a form containing a Tab Control with N pages, each page containing a subform, are those subforms loaded into memory when another page has the focus? I have tried iterating...
5
by: LabGeek | last post by:
I have an Access application that I have created that collects data from a scanner and from a weighting scale. The data from the scanner are unique identifiers (barcodes) and the scanner is...
4
by: Harlequin | last post by:
I have a question concerning the need to trigger events within a "child" subform which is itself enbedded within a master "parent" form and which is accessible via a tab in the parent form. Becuase...
9
by: frys | last post by:
Access 2003 Windows XP I have a form that is for tracking attendance at programs. the main form is the program information, and the sub form is the attendance information. I have 5 homes...
6
by: Sarvananda | last post by:
I have two forms: 1. Donor 2. Patron I want to bring the two forms together in a tab control on separate pages. I had some startup actions to be triggered for each form. Which event in the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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...

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.