Hi,
In my first post I asked some fairly generic questions and received some deserved generic answers, but at this point I'd like to post some specific code for your analysis. The new organization I've joined doesn't have any existing modules in place, it appears as though they just copy/paste code from previous macros into new ones or copy the macro itself and edit it. Furthermore, there appears to be a lot of use of ADO.
1) Will I be correct in attempting to steer users away from ADO to AccPac views? The majority of the macros are for reports so I don't think there's any data editing happening. What other reasons might there be other than existing logic in the views to use the views over ADO. Keep in mind you're not selling me, but other users (I see the inherent advantages of the existing methods and objects in the ACCPACCOMAPI).
I'd like to create a module as a sort of best practice to be added to each report and here's what I've seen on the forum so far:
In my first post I asked some fairly generic questions and received some deserved generic answers, but at this point I'd like to post some specific code for your analysis. The new organization I've joined doesn't have any existing modules in place, it appears as though they just copy/paste code from previous macros into new ones or copy the macro itself and edit it. Furthermore, there appears to be a lot of use of ADO.
1) Will I be correct in attempting to steer users away from ADO to AccPac views? The majority of the macros are for reports so I don't think there's any data editing happening. What other reasons might there be other than existing logic in the views to use the views over ADO. Keep in mind you're not selling me, but other users (I see the inherent advantages of the existing methods and objects in the ACCPACCOMAPI).
I'd like to create a module as a sort of best practice to be added to each report and here's what I've seen on the forum so far:
Code:
Option Explicit
Public sSession As AccpacCOMAPI.AccpacSession
Public mDBLinkSysRO As AccpacCOMAPI.AccpacDBLink
Public mDBLinkCmpRO As AccpacCOMAPI.AccpacDBLink
Private Sub Test()
Set sSession = New AccpacCOMAPI.AccpacSession
sSession.Init "", "XY", "XY1000", "56A"
sSession.Open "ADMIN", "ADMIN", "CMPDAT", Date, 0, 0
If sSession.IsOpened Then
Set mDBLinkSysRO = sSession.OpenDBLink(DBLINK_SYSTEM, DBLINK_FLG_READONLY)
Set mDBLinkCmpRO = sSession.OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READONLY)
End If
End Sub
[code]
I've not included the .close, = nothing for the session and the error handler yet.
2) This is the beginning of a sample module I want to create for each new report. Is what I've posted above correct? My biggest concern is what happens if a user has multiple sessions open? Also in some people's posts I see the use of AccpacSessionManager and AccpacSession instead of the AccpacCOMAPI ... I'm curious of the differences here if any?
3) The organization has varying versions of Accpac (we're upgrading, but that's an on going project) and it isn't as simple as saying "update them" so I'm wondering if the .Init will fail on previous/later versions? Are there ways around this and related concerns to doing so?