473,287 Members | 1,714 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,287 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 4959
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
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.