BallpointPenguin
Programmer
Code:
[green]'... Dimension variables ...[/green]
Dim Session As New AccpacSession
Dim dblink As AccpacDBLink
Dim ovarcustomer as AccpacView
Dim ovARCUSO as AccpacView
Dim ary5a(0) as AccpacView
Dim ary5b(0) as AccpacView
Dim llngSuccess as Long
Dim lbolTemp as Boolean
Const ACCPACuid as String = "" [green]'fill with user ID[/green]
Const ACCPACpwd as String = "" [green]'fill with password[/green]
Const ACCPACcomp as String = "" [green]'fill with company name[/green]
[green]'... Set up connection to ACCPAC ...[/green]
Session.Init("", "CS", "CS0001", "54")
Session.Open(ACCPACuid, ACCPACpwd, ACCPACcomp, Now, 0, "")
If Not Session.IsOpened Then End Sub
dblink = Session.OpenDBLink(tagDBLinkTypeEnum.DBLINK_COMPANY, tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE)
[green]'... Set up ACCPAC views ...[/green]
llngSuccess = dblink.OpenView("AR0024", ovarcustomer)
ary5a(0) = ovarcustomer
llngSuccess = dblink.OpenView("AR0400", ovARCUSO)
ary5b(0) = ovARCUSO
ovarcustomer.Compose(ary5b)
ovARCUSO.Compose(ary5a)
ovarcustomer.SystemAccess = AccpacCOMAPI.tagSystemAccessEnum.VIEW_SYSACCS_POSTING
ovARCUSO.SystemAccess = AccpacCOMAPI.tagSystemAccessEnum.VIEW_SYSACCS_POSTING
[green]'... Initialize views for customer creation ...[/green]
ovarcustomer.Init()
ovARCUSO.Init()
With ovarcustomer.fields
.FieldByName("idcust").Value = Me.CustomerID
lbolTemp = oSys.arcustomer.Exists()
oSys.arcustomer.Process()
.FieldByName("namecust").Value = Me.Bilname.Trim
[green]'... fill in with other fields ...[/green]
End With
ovarcustomer.Process()
ovarcustomer.Insert()
.
.
.
When I run this code while trying to programmatically (I hope that's spelled right!) enter a customer, I always wind up getting a "Record Already Exists" error from Accpac on the Insert command.
The customer code that I'm generating is a unique value, and I've been R'ing the FM's pretty hard. However, I'm afraid that there's something about this that I'm not quite getting, so I'm asking for help.
Again, I'm sure that it's just a single-line command of some sort, or a mis-typed command. Could anyone please help me understand what I'm overlooking?
Thanks!
John Gardner