By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,285 Members | 2,124 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,285 IT Pros & Developers. It's quick & easy.

When is a record saved?

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.