PC Review


Reply
Thread Tools Rate Thread

Test form for changes on close

 
 
JHB
Guest
Posts: n/a
 
      26th Jul 2012
Hi:

I would like to be able to test a form for changes when it is closed.
There are about 20 fields, and a change in any one will require
testing and recalculation which I do not wish to do if it isnt
necessary. Is there some simple way to test when a form is closed and
get a special response ONLY if a change has been made in the data? I
can think of a way. but it requires triggers in all fields (on
change) which will set an indicator that there had been a change in
the form content. You then test the trigger on form close, only doing
recalculation if it indicates a change has taken place.

I feel there must be a simpler way


Any suggestion much appreciated.

John Baker
 
Reply With Quote
 
 
 
 
Access Developer
Guest
Posts: n/a
 
      26th Jul 2012
The Form's Dirty property indicates a change has been made to the data
originally read and displayed on the Form for the Record.

It is often more useful to place the recalculation code in the AfterUpdate
event of a Control that requires recalculation. If the recalculations on
your Form are required for any Control being changed, and do not affect any
other calculations during process of the form, the Form's Dirty property
would be more efficient.

--
Larry Linson
Microsoft Office Access MVP
Co-Author, Microsoft Access Small Business Solutions, Wiley 2010

"JHB" <(E-Mail Removed)> wrote in message
news:0bb4238d-5bba-4311-b111-(E-Mail Removed)...
> Hi:
>
> I would like to be able to test a form for changes when it is closed.
> There are about 20 fields, and a change in any one will require
> testing and recalculation which I do not wish to do if it isnt
> necessary. Is there some simple way to test when a form is closed and
> get a special response ONLY if a change has been made in the data? I
> can think of a way. but it requires triggers in all fields (on
> change) which will set an indicator that there had been a change in
> the form content. You then test the trigger on form close, only doing
> recalculation if it indicates a change has taken place.
>
> I feel there must be a simpler way
>
>
> Any suggestion much appreciated.
>
> John Baker



 
Reply With Quote
 
 
 
 
JHB
Guest
Posts: n/a
 
      26th Jul 2012
On Jul 26, 3:49*pm, "Access Developer" <accde...@gmail.com> wrote:
> The Form's Dirty property indicates a change has been made to the data
> originally read and displayed on the Form for the Record.
>
> It is often more useful to place the recalculation code in the AfterUpdate
> event of a Control that requires recalculation. *If the recalculations on
> your Form are required for any Control being changed, and do not affect any
> other calculations during process of the form, the Form's Dirty property
> would be more efficient.
>
> *--
> *Larry Linson
> * Microsoft Office Access MVP
> * Co-Author, Microsoft Access Small Business Solutions, Wiley 2010
>
> "JHB" <bakerjo...@gmail.com> wrote in message
>
> news:0bb4238d-5bba-4311-b111-(E-Mail Removed)...
>
>
>
>
>
>
>
> > Hi:

>
> > I would like to be able to test a form for changes when it is closed.
> > There are about 20 fields, and a change in any one will require
> > testing and recalculation which I do not wish to do if it isnt
> > necessary. Is there some simple way to test when a form is closed and
> > get a special response ONLY if a change has been made in the data? I
> > can think of a way. but it requires triggers in all fields *(on
> > change) which will set an indicator that there had been a change in
> > the form content. *You then test the trigger on form close, only doing
> > recalculation if it indicates a change has taken place.

>
> > I feel there must be a simpler way

>
> > Any suggestion much appreciated.

>
> > John Baker


Thank you -- most helpful. One further question however: At what point
does the "Forms Dirty" trigger off? I only want to recalc once no
matter how many changes there are in underlying data so I am looking
for something that will trigger ONLY when the form is closed. Does
"Dirty" do it for me?

Thanks again

John Baker
 
Reply With Quote
 
Access Developer
Guest
Posts: n/a
 
      26th Jul 2012
The Form is set "Dirty" when any Control on the Form is changed. However,
you can check the property when you wish --only before saving the Record, or
only before Closing the Form, in the Event Procedure for those actions.

Note that is not pertinent to your situation, but can be useful: A "trick"
that can be used to force saving the Record displayed in a Form is to
execute the VBA code "Me.Dirty = False".

--
Larry Linson
Microsoft Office Access MVP
Co-Author, Microsoft Access Small Business Solutions, Wiley 2010

"JHB" <(E-Mail Removed)> wrote in message
news:a4188a95-6589-4bf7-8854-(E-Mail Removed)...
On Jul 26, 3:49 pm, "Access Developer" <accde...@gmail.com> wrote:
> The Form's Dirty property indicates a change has been made to the data
> originally read and displayed on the Form for the Record.
>
> It is often more useful to place the recalculation code in the AfterUpdate
> event of a Control that requires recalculation. If the recalculations on
> your Form are required for any Control being changed, and do not affect
> any
> other calculations during process of the form, the Form's Dirty property
> would be more efficient.
>
> --
> Larry Linson
> Microsoft Office Access MVP
> Co-Author, Microsoft Access Small Business Solutions, Wiley 2010
>
> "JHB" <bakerjo...@gmail.com> wrote in message
>
> news:0bb4238d-5bba-4311-b111-(E-Mail Removed)...
>
>
>
>
>
>
>
> > Hi:

>
> > I would like to be able to test a form for changes when it is closed.
> > There are about 20 fields, and a change in any one will require
> > testing and recalculation which I do not wish to do if it isnt
> > necessary. Is there some simple way to test when a form is closed and
> > get a special response ONLY if a change has been made in the data? I
> > can think of a way. but it requires triggers in all fields (on
> > change) which will set an indicator that there had been a change in
> > the form content. You then test the trigger on form close, only doing
> > recalculation if it indicates a change has taken place.

>
> > I feel there must be a simpler way

>
> > Any suggestion much appreciated.

>
> > John Baker


Thank you -- most helpful. One further question however: At what point
does the "Forms Dirty" trigger off? I only want to recalc once no
matter how many changes there are in underlying data so I am looking
for something that will trigger ONLY when the form is closed. Does
"Dirty" do it for me?

Thanks again

John Baker


 
Reply With Quote
 
Bob Quintal
Guest
Posts: n/a
 
      26th Jul 2012
JHB <(E-Mail Removed)> wrote in
news:a4188a95-6589-4bf7-8854-(E-Mail Removed):

> On Jul 26, 3:49*pm, "Access Developer" <accde...@gmail.com> wrote:
>> The Form's Dirty property indicates a change has been made to the
>> data originally read and displayed on the Form for the Record.
>>
>> It is often more useful to place the recalculation code in the
>> AfterUpdat

> e
>> event of a Control that requires recalculation. *If the
>> recalculations

> on
>> your Form are required for any Control being changed, and do not
>> affect a

> ny
>> other calculations during process of the form, the Form's Dirty
>> property would be more efficient.
>>
>> *--
>> *Larry Linson
>> * Microsoft Office Access MVP
>> * Co-Author, Microsoft Access Small Business Solutions, Wiley
>> 2010
>>
>> "JHB" <bakerjo...@gmail.com> wrote in message
>>
>> news:0bb4238d-5bba-4311-b111-(E-Mail Removed).
>> com...
>>
>>
>>
>>
>>
>>
>>
>> > Hi:

>>
>> > I would like to be able to test a form for changes when it is
>> > closed. There are about 20 fields, and a change in any one will
>> > require testing and recalculation which I do not wish to do if
>> > it isnt necessary. Is there some simple way to test when a form
>> > is closed and get a special response ONLY if a change has been
>> > made in the data? I can think of a way. but it requires
>> > triggers in all fields *(on change) which will set an indicator
>> > that there had been a change in the form content. *You then
>> > test the trigger on form close, only doin

> g
>> > recalculation if it indicates a change has taken place.

>>
>> > I feel there must be a simpler way

>>
>> > Any suggestion much appreciated.

>>
>> > John Baker

>
> Thank you -- most helpful. One further question however: At what
> point does the "Forms Dirty" trigger off? I only want to recalc
> once no matter how many changes there are in underlying data so I
> am looking for something that will trigger ONLY when the form is
> closed. Does "Dirty" do it for me?
>
> Thanks again
>
> John Baker
>


You misunderstand the .dirty property. It is not an Event.
In the form's close event you would test if the form is dirty and run
the calculations, otherwise there is no need.

Actually you will want to use the form's Before_update event do do
the recalculation, so to have the recalculation saved as well as the
changes, Form_Close is too late.

Code would look like

Private Sub Form_BeforeUpdate(Cancel As Integer)

If me.Dirty then
' do what you need to recalculate and
' put the new value in the textbox
End If
Exit Sub
End Sub

--
Bob Q.
PA is y I've altered my address.
 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      27th Jul 2012
On Thu, 26 Jul 2012 22:31:19 GMT, Bob Quintal <(E-Mail Removed)> wrote:

>You misunderstand the .dirty property. It is not an Event.


Quibble: there IS a Dirty event, as well as a Dirty property - but Bob's right
that:

>In the form's close event you would test if the form is dirty and run
>the calculations, otherwise there is no need.


So you would not need any code in the Form's Dirty event.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
Reply With Quote
 
JHB
Guest
Posts: n/a
 
      27th Jul 2012
On Jul 26, 11:47*pm, John W. Vinson
<jvinson@STOP_SPAM.WysardOfInfo.com> wrote:
> On Thu, 26 Jul 2012 22:31:19 GMT, Bob Quintal <rquin...@sPAmpatico.ca> wrote:
> >You misunderstand the .dirty property. It is not an Event.

>
> Quibble: there IS a Dirty event, as well as a Dirty property - but Bob's right
> that:
>
> >In the form's close event you would test if the form is dirty and run
> >the calculations, otherwise there is no need.

>
> So you would not need any code in the Form's Dirty event.
> --
>
> * * * * * * *John W. Vinson [MVP]
> *Microsoft's replacements for these newsgroups:
> *http://social.msdn.microsoft.com/For...-US/accessdev/
> *http://social.answers.microsoft.com/.../en-US/addbuz/
> *and see alsohttp://www.utteraccess.com


Thank you all very much..I think the light now dawns over Marblehead!

Best

John Baker
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
test test test test jadfl Microsoft Dot NET Framework 1 6th Jul 2005 06:31 AM
separating test data from test code + creating skeleton unit test classes QA Guy Microsoft C# .NET 0 6th Apr 2005 10:00 AM
separating test data from test code + creating skeleton unit test classes qualityassurance@gmail.com Microsoft C# .NET 0 6th Apr 2005 09:38 AM
Test Test Test!!!! Zero Windows XP General 2 11th Jul 2004 10:47 AM
Getting TEST!TEST!TEST message.... Narrgirl Windows XP Internet Explorer 1 21st Apr 2004 03:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:23 PM.