×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Posting an Invoice into an AccPac Batch

Posting an Invoice into an AccPac Batch

Posting an Invoice into an AccPac Batch

(OP)
Hi all,

Been reading these posts and found it to be the best info on the web at the moment.  Does anyone have some VB code to post an invoice into an open batch in AccPac.  

Can anyone help me with why I can't view the recorded Macros (in fact the Macro designer just won't open at all)

Thanks

RE: Posting an Invoice into an AccPac Batch

Did you get sorted out or are you still looking for an answer?

RE: Posting an Invoice into an AccPac Batch

I tried to do the same thing from Access 2000, but finally decided it was easier just to do a manual import from AccPac.  Before I run the import I check the next available batch number in AccPac, then update all my waiting-to-be-exported invoices with this batch number in Access.  Then I go and run the import from AccPac.

RE: Posting an Invoice into an AccPac Batch

Posting an AR invoice into accpac via VB is simple once you get the syntax down. You can use existing batches, create new ones almost anything. You will need to have the correct views declared and composed properly.

Post the code you have so far and I will have a look.

Thanks and Good Luck!

zemp

RE: Posting an Invoice into an AccPac Batch

(OP)
>Thanks for the reply.  My main problem was that I couldn't get the
>Macro functionality working on AccPac.  Now that that is working, it is
>very easy to see what code the recorded macro generates, add a few
>sessions here and there and off it goes.
>
>One question I do have at the moment is, how do you get the invoice
>number back when you create an invoice (see code below)
>
>Thanks
>
>Peter Munnings
>alias: Bladzok
>
>
>On Error GoTo ACCPACErrorHandler
>Dim session As ACCPACXAPILib.IxapiSession
>
>Set session = CreateObject("ACCPAC.xapiSession")
>session.Open "ADMIN", "ADMIN", "SAMINC", Date, 0
>
>Dim ARINVOICE3batch As ACCPACXAPILib.xapiView
>Dim ARINVOICE3batchFields As ACCPACXAPILib.xapiFields
>Set ARINVOICE3batch = session.OpenView("AR0031", "AR")
>Set ARINVOICE3batchFields = ARINVOICE3batch.Fields
>
>Dim ARINVOICE3header As ACCPACXAPILib.xapiView
>Dim ARINVOICE3headerFields As ACCPACXAPILib.xapiFields
>Set ARINVOICE3header = session.OpenView("AR0032", "AR")
>Set ARINVOICE3headerFields = ARINVOICE3header.Fields
>
>Dim ARINVOICE3detail1 As ACCPACXAPILib.xapiView
>Dim ARINVOICE3detail1Fields As ACCPACXAPILib.xapiFields
>Set ARINVOICE3detail1 = session.OpenView("AR0033", "AR")
>Set ARINVOICE3detail1Fields = ARINVOICE3detail1.Fields
>
>Dim ARINVOICE3detail2 As ACCPACXAPILib.xapiView
>Dim ARINVOICE3detail2Fields As ACCPACXAPILib.xapiFields
>Set ARINVOICE3detail2 = session.OpenView("AR0034", "AR")
>Set ARINVOICE3detail2Fields = ARINVOICE3detail2.Fields
>
>Dim ARINVOICE3batchComps(0) As ACCPACXAPILib.xapiView
>Set ARINVOICE3batchComps(0) = ARINVOICE3header ARINVOICE3batch.Compose
>ARINVOICE3batchComps
>
>Dim ARINVOICE3headerComps(2) As ACCPACXAPILib.xapiView
>Set ARINVOICE3headerComps(0) = ARINVOICE3batch
>Set ARINVOICE3headerComps(1) = ARINVOICE3detail1
>Set ARINVOICE3headerComps(2) = ARINVOICE3detail2
>ARINVOICE3header.Compose ARINVOICE3headerComps
>
>Dim ARINVOICE3detail1Comps(1) As ACCPACXAPILib.xapiView
>Set ARINVOICE3detail1Comps(0) = ARINVOICE3header
>Set ARINVOICE3detail1Comps(1) = ARINVOICE3batch
>ARINVOICE3detail1.Compose ARINVOICE3detail1Comps
>
>Dim ARINVOICE3detail2Comps(0) As ACCPACXAPILib.xapiView
>Set ARINVOICE3detail2Comps(0) = ARINVOICE3header
>ARINVOICE3detail2.Compose ARINVOICE3detail2Comps
>
>ARINVOICE3batchFields("CNTBTCH").PutWithoutVerification
>(CStr(lngBatchNo))        ' Batch Number
>
>ARINVOICE3batch.Read
>ARINVOICE3headerFields("CNTITEM").PutWithoutVerification ("0")        '
>Entry Number
>ARINVOICE3header.Browse "(CNTBTCH  = " & CStr(lngBatchNo) & "       )",
>1
>ARINVOICE3header.Fetch
>ARINVOICE3detail1.Cancel
>ARINVOICE3detail2.Cancel
>ARINVOICE3headerFields("CNTITEM").PutWithoutVerification ("0")        '
>Entry Number
>ARINVOICE3header.Init
>
>ARINVOICE3headerFields("IDCUST").Value = strCustNo
>' Customer Number
>ARINVOICE3headerFields("INVCDESC").Value = strDescription          '
>Invoice Description
>ARINVOICE3headerFields("SPECINST").Value = strSpecInstr
>
>ARINVOICE3detail1.Order = 0
>ARINVOICE3detail1.Init
>
>For i = 1 To UBound(strDistCode)
>     ARINVOICE3detail1Fields("IDDIST").Value = strDistCode(i) '
>Distribution Code
>     If strDetailDesc(i) <> "None" Then
>         ARINVOICE3detail1Fields("TEXTDESC").Value = strDetailDesc(i)
>     End If
>     ARINVOICE3detail1Fields("AMTEXTN").Value = strAmount(i)
>' Extended Amount (with TIP)
>     ARINVOICE3detail1Fields("COMMENT").Value = strComment(i)
>
>     ARINVOICE3detail1.Insert
>Next i
>
>ARINVOICE3headerFields("TEXTOPFL2").Value = "0"                       '
>Optional Field 2
>
>ARINVOICE3headerFields("TEXTOPFL3").Value = ""                        '
>Optional Field 3
>
>ARINVOICE3header.Insert
>
>ARINVOICE3headerFields("TEXTOPFL3").Value = ""                        '
>Optional Field 3
>
>
>Exit Sub
>
>ACCPACErrorHandler:
>   Dim Error As Variant
>
>   If session.Errors.Count = 0 Then
>     MsgBox Err.Description
>   Else
>     For Each Error In session.Errors
>       MsgBox Error.Description
>     Next
>     session.Errors.Clear
>   End If
>
>   Resume Next

RE: Posting an Invoice into an AccPac Batch

(OP)
Thanks for the reply.  My main problem was that I couldn’t get the Macro functionality working on AccPac.  Now that that is working, it is very easy to see what code the recorded macro generates, add a few sessions here and there and off it goes.

 

One question I do have at the moment is, how do you get the invoice number back when you create an invoice (see code below)

 

Thanks


 

On Error GoTo ACCPACErrorHandler

Dim session As ACCPACXAPILib.IxapiSession

 

Set session = CreateObject("ACCPAC.xapiSession")

session.Open "ADMIN", "ADMIN", "SAMINC", Date, 0

 

Dim ARINVOICE3batch As ACCPACXAPILib.xapiView

Dim ARINVOICE3batchFields As ACCPACXAPILib.xapiFields

Set ARINVOICE3batch = session.OpenView("AR0031", "AR")

Set ARINVOICE3batchFields = ARINVOICE3batch.Fields

 

Dim ARINVOICE3header As ACCPACXAPILib.xapiView

Dim ARINVOICE3headerFields As ACCPACXAPILib.xapiFields

Set ARINVOICE3header = session.OpenView("AR0032", "AR")

Set ARINVOICE3headerFields = ARINVOICE3header.Fields

 

Dim ARINVOICE3detail1 As ACCPACXAPILib.xapiView

Dim ARINVOICE3detail1Fields As ACCPACXAPILib.xapiFields

Set ARINVOICE3detail1 = session.OpenView("AR0033", "AR")

Set ARINVOICE3detail1Fields = ARINVOICE3detail1.Fields

 

Dim ARINVOICE3detail2 As ACCPACXAPILib.xapiView

Dim ARINVOICE3detail2Fields As ACCPACXAPILib.xapiFields

Set ARINVOICE3detail2 = session.OpenView("AR0034", "AR")

Set ARINVOICE3detail2Fields = ARINVOICE3detail2.Fields

 

Dim ARINVOICE3batchComps(0) As ACCPACXAPILib.xapiView

Set ARINVOICE3batchComps(0) = ARINVOICE3header

ARINVOICE3batch.Compose ARINVOICE3batchComps

 

Dim ARINVOICE3headerComps(2) As ACCPACXAPILib.xapiView

Set ARINVOICE3headerComps(0) = ARINVOICE3batch

Set ARINVOICE3headerComps(1) = ARINVOICE3detail1

Set ARINVOICE3headerComps(2) = ARINVOICE3detail2

ARINVOICE3header.Compose ARINVOICE3headerComps

 

Dim ARINVOICE3detail1Comps(1) As ACCPACXAPILib.xapiView

Set ARINVOICE3detail1Comps(0) = ARINVOICE3header

Set ARINVOICE3detail1Comps(1) = ARINVOICE3batch

ARINVOICE3detail1.Compose ARINVOICE3detail1Comps

 

Dim ARINVOICE3detail2Comps(0) As ACCPACXAPILib.xapiView

Set ARINVOICE3detail2Comps(0) = ARINVOICE3header

ARINVOICE3detail2.Compose ARINVOICE3detail2Comps

 

ARINVOICE3batchFields("CNTBTCH").PutWithoutVerification (CStr(lngBatchNo))        ' Batch Number

 

ARINVOICE3batch.Read

ARINVOICE3headerFields("CNTITEM").PutWithoutVerification ("0")        ' Entry Number

ARINVOICE3header.Browse "(CNTBTCH  = " & CStr(lngBatchNo) & "       )", 1

ARINVOICE3header.Fetch

ARINVOICE3detail1.Cancel

ARINVOICE3detail2.Cancel

ARINVOICE3headerFields("CNTITEM").PutWithoutVerification ("0")        ' Entry Number

ARINVOICE3header.Init

 

ARINVOICE3headerFields("IDCUST").Value = strCustNo                       ' Customer Number

ARINVOICE3headerFields("INVCDESC").Value = strDescription          ' Invoice Description

ARINVOICE3headerFields("SPECINST").Value = strSpecInstr

 

ARINVOICE3detail1.Order = 0

ARINVOICE3detail1.Init

 

For i = 1 To UBound(strDistCode)

    ARINVOICE3detail1Fields("IDDIST").Value = strDistCode(i)                    ' Distribution Code

    If strDetailDesc(i) <> "None" Then

        ARINVOICE3detail1Fields("TEXTDESC").Value = strDetailDesc(i)

    End If

    ARINVOICE3detail1Fields("AMTEXTN").Value = strAmount(i)                  ' Extended Amount (with TIP)

    ARINVOICE3detail1Fields("COMMENT").Value = strComment(i)

 

    ARINVOICE3detail1.Insert

Next i

 

ARINVOICE3headerFields("TEXTOPFL2").Value = "0"                       ' Optional Field 2

 

ARINVOICE3headerFields("TEXTOPFL3").Value = ""                        ' Optional Field 3

 

ARINVOICE3header.Insert

 

ARINVOICE3headerFields("TEXTOPFL3").Value = ""                        ' Optional Field 3

 

 

Exit Sub

 

ACCPACErrorHandler:

  Dim Error As Variant

 

  If session.Errors.Count = 0 Then

    MsgBox Err.Description

  Else

    For Each Error In session.Errors

      MsgBox Error.Description

    Next

    session.Errors.Clear

  End If

 

  Resume Next

RE: Posting an Invoice into an AccPac Batch

The only way that I know of how to get the AccPac generated invoice number is to make another call to the database and fetch it.

Thanks and Good Luck!

zemp

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close