473,657 Members | 2,555 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

When is a record saved?

Tom
Say a form has a subform, a button that pops up a message box and a cancel
button.
Q1. If data is entered in one or more fields on the main form and the user
then clicks the button that opens the message box, is the record saved?

Q2. What is the best way to determine if the main form record has been
saved so code could be written to undo the main form if the record has not
been saved and delete the record if it has been saved?

Q3. What is the best way to programatically determine if any data has been
entered in the subform yet?

Thanks!

Tom
Nov 13 '05 #1
3 6946
On Thu, 06 Jan 2005 03:26:50 GMT, "Tom" <ts******@nospa m.please>
wrote:

Q1: Yes. Any time focus shifts from parent form to child form, the
parent is saved.

Q2: After the parent record is saved, the Form_AfterUpdat e event
fires. I believe this is true for new records as well.

Q3: When the first char is entered in a new record, the
Form_BeforeInse rt event fires.

-Tom.

Say a form has a subform, a button that pops up a message box and a cancel
button.
Q1. If data is entered in one or more fields on the main form and the user
then clicks the button that opens the message box, is the record saved?

Q2. What is the best way to determine if the main form record has been
saved so code could be written to undo the main form if the record has not
been saved and delete the record if it has been saved?

Q3. What is the best way to programatically determine if any data has been
entered in the subform yet?

Thanks!

Tom


Nov 13 '05 #2
Tom wrote:
Say a form has a subform, a button that pops up a message box and a cancel
button.
Q1. If data is entered in one or more fields on the main form and the user
then clicks the button that opens the message box, is the record saved?
No, if the button is on the main form. However, you sometimes want to
save a record (perhaps to print the values) so in the OnClick event
you'd have something like
If Me.Dirty then Me.Dirty = False
in order to force a save.

Q2. What is the best way to determine if the main form record has been
saved so code could be written to undo the main form if the record has not
been saved and delete the record if it has been saved?
If Me.Dirty then...

If a record has not been modified or has been saved, it's dirty state is
False. If the record has been modified but has not been saved, it will
be dirty.

In the OnDelete event you may want to do a check like
If Me.NewRecord Then
Cancel = True
Endif
since you really can't delete a record that has not been saved.

Q3. What is the best way to programatically determine if any data has been
entered in the subform yet?

You could create a global variable. Since you wanted to know if data
has been entered...but not saved...you could use the OnChange event.
Highlight all of the subform fields and pull up the property sheet and
select Events/OnChange. Enter
=SetDataChange( )
Now create a function in the form.

Private Function SetDataChange()
blnDataChange = True
End Function

Now you can test the value anywhere in the form. Ex
If blnDataChange then...
Thanks!

Tom

Nov 13 '05 #3
Tom
Salad,

Please go to the top of the list of gurus. Your answers to all three
questions are excellent. You worded your answers perfectly and I fully
understand what you wrote. Thank you for taking the time to respond!

Sincerely,

Tom
"Salad" <oi*@vinegar.co m> wrote in message
news:rT******** *********@newsr ead3.news.pas.e arthlink.net...
Tom wrote:
Say a form has a subform, a button that pops up a message box and a cancel button.
Q1. If data is entered in one or more fields on the main form and the user then clicks the button that opens the message box, is the record saved?


No, if the button is on the main form. However, you sometimes want to
save a record (perhaps to print the values) so in the OnClick event
you'd have something like
If Me.Dirty then Me.Dirty = False
in order to force a save.

Q2. What is the best way to determine if the main form record has been
saved so code could be written to undo the main form if the record has not been saved and delete the record if it has been saved?


If Me.Dirty then...

If a record has not been modified or has been saved, it's dirty state is
False. If the record has been modified but has not been saved, it will
be dirty.

In the OnDelete event you may want to do a check like
If Me.NewRecord Then
Cancel = True
Endif
since you really can't delete a record that has not been saved.

Q3. What is the best way to programatically determine if any data has been entered in the subform yet?


You could create a global variable. Since you wanted to know if data
has been entered...but not saved...you could use the OnChange event.
Highlight all of the subform fields and pull up the property sheet and
select Events/OnChange. Enter
=SetDataChange( )
Now create a function in the form.

Private Function SetDataChange()
blnDataChange = True
End Function

Now you can test the value anywhere in the form. Ex
If blnDataChange then...
Thanks!

Tom

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4914
by: Mark | last post by:
I have a working PHP/MySQL application used for data entry. The data entry screen includes a "Save" button. The PHP code for this button looks like this: if (isset($_POST)) { if ($_POST == "") { include ("InsertRecord.inc"); // Insert new record }
12
12928
by: swingingming | last post by:
Hi, in the NorthWind sample database, when clicking on the next navigation button on the new order record with nothing on the subform (order details), we got an order with nothing ordered. How can we prevent this from happening? Thanks. ming
1
1998
by: Johann Blake | last post by:
I have a form with a single textbox control which is bound to a DataRelation in a typed dataset. The textbox displays the name of the product depending on the language selected from a combobox. When you select a different language, the textbox must show the name of the product in the selected language. This is done by setting the RowFilter property of the DefaultView on the table where the text comes from. If no text exists (that is, no...
6
5485
by: John | last post by:
Hi I need to block user from moving away from a record using any of First/Last/Prev/Next/New Record or any other way IF the record has not been saved, and displaying a message to the effect "Please finish editing". If however the user has explicitly saved the record using save from the access menu then allow to move from record. How do I achieve this via code? Thanks
7
2003
by: Ron | last post by:
Hi All, Using Access2000, winXP. Table 1 = tblClients displayed on frmClients via qryClients. 2nd table = tblInvoices shown on frmInvoices via qryInvoices. 2nd table = tblDetails shown on subform(to frmInvoices) sfrmDetails via qryDetails. Relationship built between tblClients/tblInvoices/tblDetails by ClientID. Relationship between tblInvoices/tblDetails by InvoiceID. All works fine if
1
1419
by: Macbane | last post by:
Hi, I am a bit stumped with this. I have checked the archive but I can't seem to find a problem like this. I have a form for entering a new record. I am trying to envisage the user deciding to delete the record part way through when some linked fields are not populated yet. When I click the delete button I get an error message saying that there is no corresponding entry in the linked table. I have enforced referential integrety and...
1
3233
by: google | last post by:
I have a form with several subforms. Users enter the data, then on the parent there is a command button that runs code to generate a .pdf document from a report based on the data they are working with. If a user enters data in a subform, then directly clicks the command button on the parent form, the data in the subform is not included in their document. I THOUGHT that as soon as focus left the subform, any pending changes to the data...
0
1242
by: bloukopkoggelmander | last post by:
Hi All wonderfull brains! Right I have two questions after my last very successfull thread. I have tried looking these up on the net, but no luck. Scenario 1 is : I have a bound form with bound controls. For one of the controls I look up the values from a table, but the values I then sleect from this combo box, is concatednated, ie. Lastname,Firstname,Employee number. Now what I want is that once the user has selected a concatenated name...
7
5229
by: Michiel Rapati-Kekkonen | last post by:
Hi, I would like my record to be saved only when my own close button (with all it's checks) is used. I made the winodws close button disappear, but you still can close using the right mouse click. also when designing, going to design mode saves the record. So I tried: OnClose : Me.Undo. My own cancel button uses it and it works ok,
0
8833
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8737
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8509
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7345
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.