KateHulit
asked on
VBA Automation Error
This is my code
If Answer = dcButton1 Then
Set SOPConnect = New ADODB.Connection
Set SOPRecord = New ADODB.Recordset
Set SOPConnect = UserInfoGet.CreateADOConne ction
SOPConnect.DefaultDatabase = UserInfoGet.IntercompanyID
If SalesTransactionEntry.Orig inalNumber <> "" Then DocumentNumber = SalesTransactionEntry.Orig inalNumber Else DocumentNumber = SalesTransactionEntry.Docu mentNo
cmd = "Delete from SOP10200Container where SOPNumbe = '" & DocumentNumber & "' and Lnitmseq = '" & CDbl(SalesTransactionEntry Detail.Lin eItemSeque nce) & "'"
SOPRecord.Open cmd, SOPConnect, adOpenKeyset, adLockOptimistic
End If
If Answer = dcButton2 Then
Set SOPConnect = New ADODB.Connection
Set SOPRecord = New ADODB.Recordset
Set SOPConnect = UserInfoGet.CreateADOConne ction
SOPConnect.DefaultDatabase = UserInfoGet.IntercompanyID
If SalesTransactionEntry.Orig inalNumber <> "" Then DocumentNumber = SalesTransactionEntry.Orig inalNumber Else DocumentNumber = SalesTransactionEntry.Docu mentNo
cmd = "Select * from SOP10200Container where Sopnumbe='" & DocumentNumber & "'and Lnitmseq = '" & CDbl(SalesTransactionEntry Detail.Lin eItemSeque nce) & "'"
SOPRecord.Open cmd, SOPConnect, adOpenKeyset, adLockOptimistic
If SOPRecord.EOF = False Then
SOPRecord!WrapStrap = SalesItemDetailEntry.WrapS trap
SOPRecord!Packaging = SalesItemDetailEntry.Packa ging
SOPRecord!SealNo = SalesItemDetailEntry.Seal
SOPRecord!BalesInContainer = SalesItemDetailEntry.Conta inerNoBale s
SOPRecord!ContainerWeight = SalesItemDetailEntry.Conta inerWeight
SOPRecord!ContainerMaxWeig ht = SalesItemDetailEntry.Conta inerMaxWei ght
SOPRecord!LotNumber = SalesItemDetailEntry.LotNu mber
If SalesItemDetailEntry.Conta inerNo = "" Then SOPRecord!ContainerNo = "NA" Else SOPRecord!ContainerNo = SalesItemDetailEntry.Conta inerNo
SOPRecord!Split = SalesItemDetailEntry.Split
SOPRecord.Update
End If
I entered the dcbutton2 code because when we use the delete line button on sales transaction entry in great plains and select cancel, it deletes all additional information on the item detail window. It works just fine but I get this error and do not know what it is.
Run-time error '0'
Automation error
The operation completed successfully.
Sure would like to get rid of this error.
If Answer = dcButton1 Then
Set SOPConnect = New ADODB.Connection
Set SOPRecord = New ADODB.Recordset
Set SOPConnect = UserInfoGet.CreateADOConne
SOPConnect.DefaultDatabase
If SalesTransactionEntry.Orig
cmd = "Delete from SOP10200Container where SOPNumbe = '" & DocumentNumber & "' and Lnitmseq = '" & CDbl(SalesTransactionEntry
SOPRecord.Open cmd, SOPConnect, adOpenKeyset, adLockOptimistic
End If
If Answer = dcButton2 Then
Set SOPConnect = New ADODB.Connection
Set SOPRecord = New ADODB.Recordset
Set SOPConnect = UserInfoGet.CreateADOConne
SOPConnect.DefaultDatabase
If SalesTransactionEntry.Orig
cmd = "Select * from SOP10200Container where Sopnumbe='" & DocumentNumber & "'and Lnitmseq = '" & CDbl(SalesTransactionEntry
SOPRecord.Open cmd, SOPConnect, adOpenKeyset, adLockOptimistic
If SOPRecord.EOF = False Then
SOPRecord!WrapStrap = SalesItemDetailEntry.WrapS
SOPRecord!Packaging = SalesItemDetailEntry.Packa
SOPRecord!SealNo = SalesItemDetailEntry.Seal
SOPRecord!BalesInContainer
SOPRecord!ContainerWeight = SalesItemDetailEntry.Conta
SOPRecord!ContainerMaxWeig
SOPRecord!LotNumber = SalesItemDetailEntry.LotNu
If SalesItemDetailEntry.Conta
SOPRecord!Split = SalesItemDetailEntry.Split
SOPRecord.Update
End If
I entered the dcbutton2 code because when we use the delete line button on sales transaction entry in great plains and select cancel, it deletes all additional information on the item detail window. It works just fine but I get this error and do not know what it is.
Run-time error '0'
Automation error
The operation completed successfully.
Sure would like to get rid of this error.
Could you add breakpoints and tell us where (on which line?) does it show this error?
ASKER
I stepped through it already and the error pops up as soon as you get to
SOPRecord!WrapStrap = SalesItemDetailEntry.WrapS trap
SOPRecord!WrapStrap = SalesItemDetailEntry.WrapS
In which event and which window does this code run?
ASKER
Private Sub Window_AfterModalDialog(By Val DlgType As DialogType, PromptString As String, Control1String As String, Control2String As String, Control3String As String, Answer As DialogCtrl)
In sales transaction entry window. I need to code the cancel button for when they use the insert and delete icons on the line item window.
In sales transaction entry window. I need to code the cancel button for when they use the insert and delete icons on the line item window.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Remember to close it at the end of your code, because if you opened it and hide it, you want be able to close it from the interface.
ASKER
I have to put this on hold for a minute until I get my other sql question figured out. I will then be back.
Thanks
Thanks
ASKER
found the problem. Missed a section of code in the end.
So you were having two problems, the first is you're referring to an object in a closed window (SalesItemDetailEntry), and the second one you missed a section.
Is it working now?
Is it working now?