Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 455
  • Last Modified:

VBA Automation Error

This is my code
If Answer = dcButton1 Then

            Set SOPConnect = New ADODB.Connection
            Set SOPRecord = New ADODB.Recordset

            Set SOPConnect = UserInfoGet.CreateADOConnection
            SOPConnect.DefaultDatabase = UserInfoGet.IntercompanyID

                If SalesTransactionEntry.OriginalNumber <> "" Then DocumentNumber = SalesTransactionEntry.OriginalNumber Else DocumentNumber = SalesTransactionEntry.DocumentNo
           
                    cmd = "Delete from SOP10200Container where SOPNumbe = '" & DocumentNumber & "' and Lnitmseq = '" & CDbl(SalesTransactionEntryDetail.LineItemSequence) & "'"
                    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.CreateADOConnection
            SOPConnect.DefaultDatabase = UserInfoGet.IntercompanyID
           
            If SalesTransactionEntry.OriginalNumber <> "" Then DocumentNumber = SalesTransactionEntry.OriginalNumber Else DocumentNumber = SalesTransactionEntry.DocumentNo
            cmd = "Select * from SOP10200Container where Sopnumbe='" & DocumentNumber & "'and Lnitmseq = '" & CDbl(SalesTransactionEntryDetail.LineItemSequence) & "'"
   
            SOPRecord.Open cmd, SOPConnect, adOpenKeyset, adLockOptimistic
           
                If SOPRecord.EOF = False Then
           
                    SOPRecord!WrapStrap = SalesItemDetailEntry.WrapStrap
                    SOPRecord!Packaging = SalesItemDetailEntry.Packaging
                    SOPRecord!SealNo = SalesItemDetailEntry.Seal
                    SOPRecord!BalesInContainer = SalesItemDetailEntry.ContainerNoBales
                    SOPRecord!ContainerWeight = SalesItemDetailEntry.ContainerWeight
                    SOPRecord!ContainerMaxWeight = SalesItemDetailEntry.ContainerMaxWeight
                    SOPRecord!LotNumber = SalesItemDetailEntry.LotNumber
                    If SalesItemDetailEntry.ContainerNo = "" Then SOPRecord!ContainerNo = "NA" Else SOPRecord!ContainerNo = SalesItemDetailEntry.ContainerNo
                    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.
0
KateHulit
Asked:
KateHulit
  • 5
  • 4
1 Solution
 
Abdulmalek_HamshoCommented:
Could you add breakpoints and tell us where (on which line?) does it show this error?
0
 
KateHulitAuthor Commented:
I stepped through it already and the error pops up as soon as you get to

SOPRecord!WrapStrap = SalesItemDetailEntry.WrapStrap
0
 
Abdulmalek_HamshoCommented:
In which event and which window does this code run?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
KateHulitAuthor Commented:
Private Sub Window_AfterModalDialog(ByVal 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.
0
 
Abdulmalek_HamshoCommented:
But you're referring to fields in SalesItemDetailEntry while this window is closed.

You need to open The SalesItemDetailEntry window right after this statement:

If SOPRecord.EOF = False Then


You can make it hidden if you want.
0
 
Abdulmalek_HamshoCommented:
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.
0
 
KateHulitAuthor Commented:
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
0
 
KateHulitAuthor Commented:
found the problem.  Missed  a section of code in the end.
0
 
Abdulmalek_HamshoCommented:
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?
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now