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

Is a transaction open?

P: 20
Hey there--

This seems a pretty simple question, but I haven't been able to find an answer anywhere.

I'm wondering if there's any method or property in Access (2003) that would show the current transaction state.

The help file says "If you use the CommitTrans or Rollback method without first using the BeginTrans method, an error occurs." So in my error handler, I'd like to check to see if a transaction was started, and if so, roll it back.

Obviously, I could just set a boolean flag myself, but if there's a method I could use instead, I'd prefer that.

Thanks
Sep 13 '07 #1
Share this Question
Share on Google+
6 Replies


Scott Price
Expert 100+
P: 1,384
Hey there--

This seems a pretty simple question, but I haven't been able to find an answer anywhere.

I'm wondering if there's any method or property in Access (2003) that would show the current transaction state.

The help file says "If you use the CommitTrans or Rollback method without first using the BeginTrans method, an error occurs." So in my error handler, I'd like to check to see if a transaction was started, and if so, roll it back.

Obviously, I could just set a boolean flag myself, but if there's a method I could use instead, I'd prefer that.

Thanks

Well, ADO supplies the State functions, but that only applies to Objects... giving adStateOpen, adStateExecuting, adStateFetching, etc.

As far as I know transactions don't support the ability to see if they are currently running or not. Seems like I've seen a similar post somewhere on this site... let me investigate a bit and see if there's another answer to this.

Regardless of the other post, I think you're probably better off writing this part of your error handling into the individual sub that has a transaction started... Then you just need to put the appropriate RollBackTrans command into your Error label commands, something like the Exit Sub command that is ubiquitous in error handlers.



Regards,
Scott
Sep 14 '07 #2

Scott Price
Expert 100+
P: 1,384
Have a look here at these two tutorials:

ADO Transaction Processing

And DAO Transaction Processing

Regards,
Scott
Sep 14 '07 #3

P: 20
...
And DAO Transaction Processing
Ahh.. ok. In this tip, ADezii sets a boolean to track the state of the transaction. That's what I ended up doing, though it seems a bit shortsighted on Microsoft's part not to include a property in the Workspace object showing the current state of a transaction (or even better, the level of transaction that's open, which would show nesting).

But then again, when has Microsoft ever thought ahead...??

Thanks for the links. It's kinda weird they didn't show up in the search. I thought "access transactions" was a general enough search... *shrug*

Thanks again.
Sep 14 '07 #4

Scott Price
Expert 100+
P: 1,384
Farsighted.... Hmmm... Depends on which area of 'farsightedness' you are thinking of :-) They sure seem to be farsighted in the revenue department!

Like a Civil War general once said (can't remember which one) the secret to winning a battle is :"Get there the firstest with the mostest..."

With all their faults one thing M$ has consistently done is never get stuck perfecting a given application for a given level of technological complexity.

That roughly translates into aiming for an *acceptable* level of mediocrity, release bug patches as needed, and pour most of your R&D dollars into the next anticipated level of complexity. Seems to work when you look at their bottom line, but leaves most of us frustrated most of the time...

All right, enough ranting on my soapbox :-)

Glad you found something that will work for you!

Regards,
Scott
Sep 14 '07 #5

P: 20
HAHAHA! Nice!

been thinking all this for awhile, huh?
Sep 14 '07 #6

Scott Price
Expert 100+
P: 1,384
HAHAHA! Nice!

been thinking all this for awhile, huh?

Too long :-)

Regards,
Scott
Sep 14 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.