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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to update records not created using Accpac views

Status
Not open for further replies.

borgus

Programmer
Oct 19, 2003
2
ZA
HI

We used to manipulate the data within ARCUS through direct SQL and are currently in the process of changing this to run through Accpac views. When I try to update ARCUS using a record created with the views the update works, however when I try and manipulate an old record I get the following error message:
Error number: -2147467259
The "Session" object was not opened.

The code I am using is and the function fails on the following line of code "ARCUSTOMER5.Update":

Public Function EditMemberDetails(MemNo As Variant, Address1 As Variant, Address2 As Variant, Address3 As Variant, City As Variant, Province As Variant, Code As Variant, _
Contact As Variant, Phone As Variant, Fax As Variant, ContactEmail As Variant, CompEmail As Variant, WebSite As Variant) As Boolean

On Error GoTo ex

Dim Session As AccpacCOMAPI.AccpacSession
Set Session = New AccpacCOMAPI.AccpacSession

Session.Init "", "AS", "AS1000", "50A"
Session.Open "ADMIN", "ADMIN", "RMICON", Date, 0, ""

Dim CompanyLink As AccpacCOMAPI.AccpacDBLink
Set CompanyLink = Session.OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)

Dim ARCUSTOMER5 As AccpacCOMAPI.AccpacView
Dim ARCUSTOMER5Fields As AccpacCOMAPI.AccpacViewFields
CompanyLink.OpenView "AR0024", ARCUSTOMER5
Set ARCUSTOMER5Fields = ARCUSTOMER5.Fields

ARCUSTOMER5.Browse "(IDCUST = """ & MemNo & """)", 1

ARCUSTOMER5.Fetch

ARCUSTOMER5Fields("TEXTSTRE1").PutWithoutVerification (Address1) ' Address Line 1
ARCUSTOMER5Fields("TEXTSTRE2").PutWithoutVerification (Address2) ' Address Line 2
ARCUSTOMER5Fields("TEXTSTRE3").PutWithoutVerification (Address3) ' Address Line 2
ARCUSTOMER5Fields("NAMECITY").PutWithoutVerification (City) ' City
ARCUSTOMER5Fields("CODESTTE").PutWithoutVerification (Province) ' State/Prov.
ARCUSTOMER5Fields("CODEPSTL").PutWithoutVerification (Code) ' Zip/Postal Code
ARCUSTOMER5Fields("CODECTRY").PutWithoutVerification ("ZA") ' Country

ARCUSTOMER5Fields("NAMECTAC").PutWithoutVerification (Contact) ' Contact Name
ARCUSTOMER5Fields("TEXTPHON1").PutWithoutVerification (Phone) ' Phone Number
ARCUSTOMER5Fields("TEXTPHON2").PutWithoutVerification (Fax) ' Fax Number

ARCUSTOMER5Fields("EMAIL1").PutWithoutVerification (ContactEmail) ' Contact's E-mail
ARCUSTOMER5Fields("EMAIL2").PutWithoutVerification (CompEmail) ' E-mail
ARCUSTOMER5Fields("WEBSITE").PutWithoutVerification (WebSite) ' Web Site

ARCUSTOMER5.Update

EditMemberDetails = True
Exit Function

ex:
Dim lCount As Long
Dim lIndex As Long

If Errors Is Nothing Then
MsgBox Err.Description
MsgBox "VBA Macros cannot run where Accpac is deployed as a Web Server"
Else
lCount = Errors.Count

If lCount = 0 Then
MsgBox Err.Description
Else
For lIndex = 0 To lCount - 1
MsgBox Errors.Item(lIndex)
Next
Errors.Clear
End If
Resume Next

End If
End Function

Can anyone offer any assistance?

Thanks

Russel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top