CurrentProject.Connection

  • Thread starter Thread starter Jorge Viñuales
  • Start date Start date
J

Jorge Viñuales

I use CurrentProject.Connection, to send several update querys to SQL.
I try to open a transaction before the updates. Then when I finish, I try to
end the transaction with currentProject.CommitTran.
But in that point, I get an error, saying that there's no transaction
active.

¿Any help?
Thanks
 
Jorge

In order go begin transaction you need to create Cnn object, adjust the
CurrentProject.Connection and on your local variable you can do the
transaction

For example:

' create variable
Dim cnn as ADODB.Connection

' adjust CurrentProject.Connection to your variable
Set cnn = CurrentProject.Connection

' begin your transaction
cnn.BeginTrans

' do what you want to do

'and at the end
cnn.CommitTrans

I also recemend you to use error handler there.

In the error handler use the - cnn.RollbackTrans
to cancel the action you did

Good luck
 
Thank you Roy.

Roy Goldhammer said:
Jorge

In order go begin transaction you need to create Cnn object, adjust the
CurrentProject.Connection and on your local variable you can do the
transaction

For example:

' create variable
Dim cnn as ADODB.Connection

' adjust CurrentProject.Connection to your variable
Set cnn = CurrentProject.Connection

' begin your transaction
cnn.BeginTrans

' do what you want to do

'and at the end
cnn.CommitTrans

I also recemend you to use error handler there.

In the error handler use the - cnn.RollbackTrans
to cancel the action you did

Good luck


try
 
Back
Top