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

a2k - using bound subforms and transations

P: n/a
There's an interesting chapter on this in the Access 2000 Developer's
Handbook (chapter 8) but I'm trying to rework the code so the user has the
option of saving changes or rolling them back.

There is a boolean transaction variable that tracks whether the code is in a
transaction. If this is true the unload event fires and asks if changes
should be saved.

However this will also fire if the user *hasn't* made any changes. So is it
possible to track if any changes have been made within the scope of the
transaction?

Is this the RecordsAffected property? I'm trying trial and error here and
the lousy help files aren't , er, helping.

thanks
Martin
--

Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
That's the code that opens a transaction, opens a recordset, and then
assigns it to the Recordset of the form, so the form is operating within
your transaction?

Your subject line suggests you are trying to trying to do this with a bound
subform. If the subform control has LinkMasterFields/LinkChildFields set,
then Access will reload the subform every time time main form changes
record, so the attempt to assign a Recordset to the subform is not practical
in this scenario.

AFAIK, there is no way to wrap the main form and this kind of subform inside
a transaction so you can commit/rollback all the changes to both when the
main form closes.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Deano" <de***@mailinator.com> wrote in message
news:42**********************@ptn-nntp-reader04.plus.net...
There's an interesting chapter on this in the Access 2000 Developer's
Handbook (chapter 8) but I'm trying to rework the code so the user has the
option of saving changes or rolling them back.

There is a boolean transaction variable that tracks whether the code is in
a
transaction. If this is true the unload event fires and asks if changes
should be saved.

However this will also fire if the user *hasn't* made any changes. So is
it
possible to track if any changes have been made within the scope of the
transaction?

Is this the RecordsAffected property? I'm trying trial and error here and
the lousy help files aren't , er, helping.

thanks
Martin

Nov 13 '05 #2

P: n/a
Allen Browne wrote:
That's the code that opens a transaction, opens a recordset, and then
assigns it to the Recordset of the form, so the form is operating
within your transaction?

Your subject line suggests you are trying to trying to do this with a
bound subform. If the subform control has
LinkMasterFields/LinkChildFields set, then Access will reload the
subform every time time main form changes record, so the attempt to
assign a Recordset to the subform is not practical in this scenario.

AFAIK, there is no way to wrap the main form and this kind of subform
inside a transaction so you can commit/rollback all the changes to
both when the main form closes.

You're correct. The example in the book says you must manage the links
yourself. Once you do that you can perform transactions on a bound subform,
the example mdb on the CD certainly proves that. It's just that it only
offers undo functionality, though the authors suggest you can modify the
code to ask if changes should be saved as well.
That's where I am but i need to know if the user has actually changed any
data that would need saving/rolling back. As it stands they ALWAYS get the
prompt and that's what I'm trying to fix.
--
Nov 13 '05 #3

P: n/a
Deano wrote:
Allen Browne wrote:
That's the code that opens a transaction, opens a recordset, and then
assigns it to the Recordset of the form, so the form is operating
within your transaction?

Your subject line suggests you are trying to trying to do this with a
bound subform. If the subform control has
LinkMasterFields/LinkChildFields set, then Access will reload the
subform every time time main form changes record, so the attempt to
assign a Recordset to the subform is not practical in this scenario.

AFAIK, there is no way to wrap the main form and this kind of subform
inside a transaction so you can commit/rollback all the changes to
both when the main form closes.

You're correct. The example in the book says you must manage the
links yourself. Once you do that you can perform transactions on a
bound subform, the example mdb on the CD certainly proves that. It's
just that it only offers undo functionality, though the authors
suggest you can modify the code to ask if changes should be saved as
well.
That's where I am but i need to know if the user has actually changed
any data that would need saving/rolling back. As it stands they
ALWAYS get the prompt and that's what I'm trying to fix.


Actually just checked this, it rolls back main form changes as well. Cool.

--
Nov 13 '05 #4

P: n/a
Could you declare a form level boolean variable in the form's module's
General Declarations:
Dim bHasChanged As Boolean
and set it to True in the form's AfterUpdate event?

You could then test the variable to see if there are changes to confirm with
the user.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Deano" <de***@mailinator.com> wrote in message
news:42**********************@ptn-nntp-reader04.plus.net...
Allen Browne wrote:
That's the code that opens a transaction, opens a recordset, and then
assigns it to the Recordset of the form, so the form is operating
within your transaction?

Your subject line suggests you are trying to trying to do this with a
bound subform. If the subform control has
LinkMasterFields/LinkChildFields set, then Access will reload the
subform every time time main form changes record, so the attempt to
assign a Recordset to the subform is not practical in this scenario.

AFAIK, there is no way to wrap the main form and this kind of subform
inside a transaction so you can commit/rollback all the changes to
both when the main form closes.

You're correct. The example in the book says you must manage the links
yourself. Once you do that you can perform transactions on a bound
subform,
the example mdb on the CD certainly proves that. It's just that it only
offers undo functionality, though the authors suggest you can modify the
code to ask if changes should be saved as well.
That's where I am but i need to know if the user has actually changed any
data that would need saving/rolling back. As it stands they ALWAYS get
the
prompt and that's what I'm trying to fix.

Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.