Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sample ACCPAC XAPI Code 2

Status
Not open for further replies.

Simboti1

IS-IT--Management
Sep 12, 2008
31
BW
Can anyone help? I am converting a VB6 application so that it fetches data from GL0018 view instead of the convensional SQL code. I need XAPI code that will achieve what the following SQL code is doing?

1. SELECT FISCALYR AS FSC_YEAR, JRNLDATE AS DOC_DATE FROM GLPOST WHERE ACCTID = '4020'
AND FSCALYR = '2009'
AND FSCALPERD >= '01'
AND FSCALPERD <= '12'


2. SELECT COUNT(*) FROM GLPOST WHERE ACCTID = '4020'
AND FSCALYR = '2009'
AND FSCALPERD >= '01'
AND FSCALPERD <= '12'

I need 2. because I want to use the VB progress bar)
 
Code:
Dim strFilter As String

Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
Dim GLPOST As AccpacCOMAPI.AccpacView

Set mDBLinkCmpRW = OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READONLY) 'Note read only is faster
mDBLinkCmpRW.OpenView "GL0018", GLPOST

strFilter = "ACCTID=4020 and FISCALYR=2009 AND FISCALPERD>=01 and FISCALPERD<=12"

MsgBox GLPOST.FilterCount(strFilter, 0)  'Number of records

GLPOST.Browse strFilter, True

Do While GLPOST.GoNext
    'Do your stuff
Loop

GLPOST.Close
mDBLinkCmpRW.Close

Set GLPOST = Nothing
Set mDBLinkCmpRW = Nothing
 
As an aside, using ODBC to read from the Accpac data and using COM to update Accpac can give you better overall performance in some cases.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top