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

Macro showing Accpac UI and two databases at the same time

Status
Not open for further replies.

Anoli

Programmer
Jan 26, 2001
13
CA
I have a macro containing a form showing an Accpac UI and when I am logged onto one database works OK, if I am logged in two databases at the same time it shows the Accpac Log-on screen before showing the form/UI and I must create a new session before it continues, otherwise it cannot open the UI. How can I make the UI pick up the session that I am already in?

I did some more testing: the screen I am using is a Project and Job Cost 53B
I noticed that when I have two companies open and I run the macro it asks to log in and after selecting the user name, password and company ID it opens the screen.
At the same time it creates a new session ID in the Accpac sign on manager.
This is a "sticky" session that does not close by itself even when all Accpac windows are close.
This session remember which company I logged on when I tried to run the macro and if I log onto another company and try the macro it does not ask to log in but is uses that "sticky" session.
Therefore, I might be in company A, run the macro, but the UI in the macro is connected to company B
Above testing was done in 5.4 SM with 53B job cost.

However, if I use the macro in a 53 System Manager environment when running the macro with two companies open it brings up the Signon manager asking to select which existing session I want to use (or create a new sign on).
The macro attaches to the selected session and runs OK and when I close all Accpac Windows all sessions disappear from the sign on manager


So what I am trying to accomplish is:
- either replicate the SM53 behavior in 54 and be able to choose an existing session from the sign on manager
or - if I must create a new session have that session disappear from the sign on manager when macro finishes running

I have not posted any code because the above behavior occurs even in the simplest scenario: show form with Accpac screen on it, without any other code.

I appreciate any suggestions you might have.
Thank you.
 
(Copied from the other VBA forum, you need a Sessionmgr object:)

In your project, you need references to:

ACCPAC COM API Object 1.0
ACCPAC Session Manager Object 1.0
(to add the references, use Project->References)

You should declare the session as a class-wide (form-wide) variable near the top of the file:

Private mSession As AccpacSession
Private mSessMgr As AccpacSessionMgr ' this is useful if you need to use the AccpacMeter

In your startup code (perhaps Form_Load?), you should have:

Dim lSignonID As Long

lSignonID = 0 ' MUST be initialized to 0 since you don't have a signon ID yet
Set mSessMgr = New AccpacSessionMgr
With mSessMgr
.AppID = "BK"
.AppVersion = "51A"
.ProgramName = "BK2001"
.ServerName = "" ' empty string if running on local computer
.CreateSession "", lSignonID, mSession ' first argument is the object handle (if you don't have one, pass "")
End With ' mSessMgr


With dsCUST ' Just example useage.
.Session = mSession
.Active = True
End With ' dsCUST

feCustNum.DataSource = dsCUST


In your cleanup code (perhaps Form_Unload?), you should have:

dsCUST.Active = False
mSession.Close
Set mSession = Nothing
Set mSessMgr = Nothing ' no longer used
 
Hi there:
Thank you for your help, I managed to make the macro open its own session and close it at the end.
Still have to revise some small issues but you provided me with very useful info.
Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top