Opa, desculpe a demora... rs
Consegui algo que funcionou legal!
'TRANSACTION ADO
'========================================================================================================
On Error GoTo ErrorHandler
With cnnBDPortaria
.BeginTrans
'.Execute "UPDATE Logistica SET Paletizada = 'Sim' ,Cliente = '" & Me.cmbCliente & "', Qtd_Entrada = '" & Me.txtEntrada & "', " & _
"Qtd_Saida = '" & Me.txtSaida & "', Qtd_vPaletes = '" & Me.txtVPaletes & "', Cli_vPaletes = '" & vCliente & "' " & _
"WHERE Protocolo = " & Logistica!Protocolo & ""
'Paletes Entrando
If Me.txtEntrada <> "" And Me.txtEntrada > 0 Then
pal_Scarlat.Open ("SELECT * FROM pal_Scarlat"), cnnBDPortaria, adOpenKeyset, adLockOptimistic
.Execute "UPDATE pal_Scarlat set Conforme =" & (pal_Scarlat!Conforme + Me.txtEntrada) & ""
pal_Scarlat.Close
pal_Clientes_Transp.Open ("SELECT * FROM pal_Clientes_Transp Where Nome = '" & Me.cmbCliente & "'"), cnnBDPortaria, adOpenKeyset, adLockOptimistic
.Execute "UPDATE pal_Clientes_Transp set QTD =" & (pal_Clientes_Transp!QTD - Me.txtEntrada) & " Where Nome = '" & Me.cmbCliente & "'"
pal_Clientes_Transp.Close
End If
'Vale Paletes Entrando
If Me.txtVPaletes <> "" And Me.txtVPaletes > 0 Then
pal_Clientes_Transp.Open ("SELECT * FROM pal_Clientes_Transp Where Nome = '" & vCliente & "'"), cnnBDPortaria, adOpenKeyset, adLockOptimistic
.Execute "UPDATE pal_Clientes_Transp set QTD =" & (pal_Clientes_Transp!QTD + Me.txtVPaletes) & " Where Nome = '" & vCliente & "'"
pal_Clientes_Transp.Close
pal_Clientes_Transp.Open ("SELECT * FROM pal_Clientes_Transp Where Nome = '" & Me.cmbCliente & "'"), cnnBDPortaria, adOpenKeyset, adLockOptimistic
.Execute "UPDATE pal_Clientes_Transp set QTD =" & (pal_Clientes_Transp!QTD - Me.txtVPaletes) & " Where Nome = '" & Me.cmbCliente & "'"
pal_Clientes_Transp.Close
End If
'Paletes Saindo
If Me.txtSaida <> "" And Me.txtSaida > 0 Then
pal_Scarlat.Open ("SELECT * FROM pal_Scarlat"), cnnBDPortaria, adOpenKeyset, adLockOptimistic
.Execute "UPDATE pal_Scarlat set Conforme =" & (pal_Scarlat!Conforme - Me.txtSaida) & ""
pal_Scarlat.Close
pal_Clientes_Transp.Open ("SELECT * FROM pal_Clientes_Transp Where Nome = '" & Me.cmbCliente & "'"), cnnBDPortaria, adOpenKeyset, adLockOptimistic
.Execute "UPDATE pal_Clientes_Transp set QTD =" & (pal_Clientes_Transp!QTD + Me.txtSaida) & " Where Nome = '" & Me.cmbCliente & "'"
pal_Clientes_Transp.Close
End If
.CommitTrans
End With
ExitHere:
MsgBox "Finalizado com sucesso!", vbInformation, "LOGÍSTICA"
vCliente = Empty
cmdFim_Carreg.Enabled = False
Exit Sub
ErrorHandler:
MsgBox Err.Description
With cnnBDPortaria
.RollbackTrans
End With
Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel
Postado : 14/10/2010 7:06 am