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

Saving the last value in a sub form

I'm in Access 2007. I built a feature that to saves the current list in a sub form to a separate table. It works like this: After entering a list of words in the subform, the user can choose to push a button, and a dialog box appears. The user enters a name into the dialog box to identify the list for later use, presses OK and the list is saved.

In the code, I'm using DoCmd.RunSql on the data in the table, so all the data in the sub form needs to be saved to the underlying table in order for the feature to work properly.

The problem occurs on the last item of data in the sub form. If I enter data into the last field, and I do not hit enter/return, and I go right to pressing the button to save the list, the data in the last field will not get saved because it was not saved to the table.

If I attempt to force a save with something like Docmd.RunCommand acSave, I cause 2 problems: 1) If the user did hit return and the data is saved, calling acSave can produce and error. 2) I only want to save the data in the subform. I do not want to apply acSave to the main form.

I assume I need some code in the feature-button to save the last item in the sub form, but I don't know what it should be. Can anyone tell me how I can correct this feature so the last piece of data in the subform is stored in the underlying table, regardless of if the user pressed enter/return?

Thanks,
Adam
Dec 15 '09 #1
1 4981
missinglinq
3,532 Expert 2GB
If Me.Dirty Then Me.Dirty = False only saves the record if it is unsaved.

DoCmd.RunCommand acCmdSaveRecord can also be used, and doesn't throw an error if the record is already saved.

Thirdly, you could simply move off of the subform, to the main form, before running your other code, and the record would be saved.

BTW, Docmd.RunCommand acCmdSave, which is the actual syntax, not acSave,does not save a record! It saves changes to the design of the form!

Linq ;0)>
Dec 15 '09 #2

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

Similar topics

0
by: mchl gdbt | last post by:
Hi, I have several thousand tiffs generated by application A which are read by application B. I need to remove a few colours from the tiffs and I decided to try with the python imaging library....
10
by: Geoff Cox | last post by:
Hello, I have a series of pages each of which creates an array of values. How do I keep all the array values until the last page? Cheers Geoff
2
by: PMB | last post by:
Thank you in advance for any and all assistance. I'm trying to keep my numbers for transactions sequential. I clear my monthly transactions each month and store them in a general transactions...
13
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've...
3
by: RCS | last post by:
I have an app that I have different "sections" that I want to switch back and forth from, all while having the server maintain viewstate for each page. In other words, when I am on Page1.aspx and...
18
by: TORQUE | last post by:
Hi, Im wondering if anyone can help me with a problem. I have a form with more than 50 unbound fields. Some of the fields will be blank from time to time. This seems to be where im having...
5
by: Colleyville Alan | last post by:
I have an Access app which uses Office Automation to manipulate and then save PowerPoint files to disk. It works fine, but I need to update the code and I am having problems with the syntax. ...
5
by: deekay | last post by:
I want to allow users to resize and reposition columns of a datasheet but for a prompt to be brought up and only the layout only to be saved if they select "save changes". This is the way it works...
9
by: Wingot | last post by:
Hey, I am using Visual Studio 2008 Beta 2 for some application development in C#, but I presume that the following question applies equally well to any environment.
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.