I am using ACCPAC 5.2A version with all the service pack 4 installed and MS SQL server.
Following code generates error: Session is not initialized
Dim AccSession As New AccpacCOMAPI.AccpacSession
Dim CompDBLink As AccpacCOMAPI.AccpacDBLink
Dim AcPkView As AccpacCOMAPI.AccpacView
Dim strFilter As String
Dim strItemNo As String
On Error GoTo ACCPACErrorHandler
If AccSession.IsOpened Then
CompDBLink.Close
AccSession.Close
End If
AccSession.Init "", "IC", "IC1130", "52A" 'Prog ID Location Details
AccSession.EnforceAppVersion = False
AccSession.Open "ADMIN", "ADMIN", "IC707D", Date, 0, ""
Set CompDBLink = AccSession.OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)
CompDBLink.OpenView "IC2090", AcPkView 'View ID Locational Details
With AcPkView
.Init
strFilter = "(ITEMNO = " + strItemNo + ")"
.Browse strFilter, True
Do While .Fetch
strItemNo = .Fields("LOCATION")
Loop
.Close
Set AcPkView = Nothing
End With
Set CompDBLink = Nothing
This piece of code works fine till code: Set CompDBLink.....
On encountering the line "CompDBLink.OpenView "IC2090", AcPkView", it generates error "Session not initialized". The value of "AccSession.IsOpened" is TRUE.
I searched the forum and found that I am following the correct syntax. Still I am getting this error. Can someone Help to resolve this?
Following code generates error: Session is not initialized
Dim AccSession As New AccpacCOMAPI.AccpacSession
Dim CompDBLink As AccpacCOMAPI.AccpacDBLink
Dim AcPkView As AccpacCOMAPI.AccpacView
Dim strFilter As String
Dim strItemNo As String
On Error GoTo ACCPACErrorHandler
If AccSession.IsOpened Then
CompDBLink.Close
AccSession.Close
End If
AccSession.Init "", "IC", "IC1130", "52A" 'Prog ID Location Details
AccSession.EnforceAppVersion = False
AccSession.Open "ADMIN", "ADMIN", "IC707D", Date, 0, ""
Set CompDBLink = AccSession.OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)
CompDBLink.OpenView "IC2090", AcPkView 'View ID Locational Details
With AcPkView
.Init
strFilter = "(ITEMNO = " + strItemNo + ")"
.Browse strFilter, True
Do While .Fetch
strItemNo = .Fields("LOCATION")
Loop
.Close
Set AcPkView = Nothing
End With
Set CompDBLink = Nothing
This piece of code works fine till code: Set CompDBLink.....
On encountering the line "CompDBLink.OpenView "IC2090", AcPkView", it generates error "Session not initialized". The value of "AccSession.IsOpened" is TRUE.
I searched the forum and found that I am following the correct syntax. Still I am getting this error. Can someone Help to resolve this?