Justin9999
Programmer
Hi,
Can anyone tell whats wrong with this code? I have added a reference to "ACCPAC COM API Object 1.0". It seems to opening the session ok.
Public Sub Add_Dist_Code(DistCode As String, glAccount As String, Description As String)
'
' Recorded at: Fri Aug 05 13:47:18 2011
'
Dim Session As AccpacCOMAPI.AccpacSession
Set Session = CreateObject("Accpac.Session")
'Open accpac session
Session.Init "", "AS", "AS9031", "56A"
Session.Open "JUSTIN", "whatever", "ANGDAT", Date, 0, ""
On Error GoTo ACCPACErrorHandler
' TODO: To increase efficiency, comment out any unused DB links.
'HAS A PROBLEM WITH LINE BELOW **********************************
Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkCmpRW = OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)
Dim mDBLinkSysRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkSysRW = OpenDBLink(DBLINK_SYSTEM, DBLINK_FLG_READWRITE)
Dim temp As Boolean
Dim APDISTCODE1 As AccpacCOMAPI.AccpacView
Dim APDISTCODE1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0005", APDISTCODE1
Set APDISTCODE1Fields = APDISTCODE1.Fields
APDISTCODE1.Init
APDISTCODE1Fields("DISTID").Value = DistCode ' Distribution Code
temp = APDISTCODE1.Exists
APDISTCODE1Fields("IDGLACCT").Value = glAccount ' G/L Account
APDISTCODE1Fields("TEXTDESC").PutWithoutVerification (Description) ' Description
APDISTCODE1Fields("SWDISCABL").PutWithoutVerification ("0") ' Discountable
APDISTCODE1.Insert
Exit Sub
Thanks in advance for any help.
Justin
Can anyone tell whats wrong with this code? I have added a reference to "ACCPAC COM API Object 1.0". It seems to opening the session ok.
Public Sub Add_Dist_Code(DistCode As String, glAccount As String, Description As String)
'
' Recorded at: Fri Aug 05 13:47:18 2011
'
Dim Session As AccpacCOMAPI.AccpacSession
Set Session = CreateObject("Accpac.Session")
'Open accpac session
Session.Init "", "AS", "AS9031", "56A"
Session.Open "JUSTIN", "whatever", "ANGDAT", Date, 0, ""
On Error GoTo ACCPACErrorHandler
' TODO: To increase efficiency, comment out any unused DB links.
'HAS A PROBLEM WITH LINE BELOW **********************************
Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkCmpRW = OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)
Dim mDBLinkSysRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkSysRW = OpenDBLink(DBLINK_SYSTEM, DBLINK_FLG_READWRITE)
Dim temp As Boolean
Dim APDISTCODE1 As AccpacCOMAPI.AccpacView
Dim APDISTCODE1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0005", APDISTCODE1
Set APDISTCODE1Fields = APDISTCODE1.Fields
APDISTCODE1.Init
APDISTCODE1Fields("DISTID").Value = DistCode ' Distribution Code
temp = APDISTCODE1.Exists
APDISTCODE1Fields("IDGLACCT").Value = glAccount ' G/L Account
APDISTCODE1Fields("TEXTDESC").PutWithoutVerification (Description) ' Description
APDISTCODE1Fields("SWDISCABL").PutWithoutVerification ("0") ' Discountable
APDISTCODE1.Insert
Exit Sub
Thanks in advance for any help.
Justin