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

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 6920
On Thu, 06 Jan 2005 03:26:50 GMT, "Tom" <ts******@nospam.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_AfterUpdate 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_BeforeInsert 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.com> wrote in message
news:rT*****************@newsread3.news.pas.earthl ink.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
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 ==...
12
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...
1
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....
6
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...
7
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...
1
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...
1
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...
0
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...
7
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...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...

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.