ADP- Connection Dialog

  • Thread starter Thread starter Svetlana
  • Start date Start date
S

Svetlana

Hallo
I am running an Access 2002-adp project + SQL Server 2000
and seeking the solution to display a login dialog, where
users can enter their ID and Pwd.
I've upsized a mdb to adp (Access XP) under SA rights and
now the SA comes every time, as a user opens this
application. Have you got any idea how to display the
most recently logged-in user instead of SA? Thanks!
 
Hi Svetlana,

The only way to do this would be to control the login process
programmatically. The SA user comes up because that is the account that
was likely used to create the initial connection for the ADP and so that
info is stored in the file's connection properties.

There are a couple of different steps to solving your problem. The first
is to use a custom logon form and perform the connection yourself using the
currentproject.openconnection method. This will replace any existing
connection info with that of the new connection info.

Secondly, for your own code to run without getting prompted by Access'
built-in login prompt, you will need to clear the connection info before
closing the application so that the app opens in a disconnected state the
next time around. This is done by passing a blank connection argument for
the openconnection method, as follows:

currentproject.openconnection ""

I usually hide the initial login form after I'm done with it and then have
this code run in the close event of the login form. The next time the app
is opened, your code can prompt the user for security credentials. However,
if you want to pre-populate the userid with the id of the last user, then
you will need to store and retrieve the data yourself because it will be
lost when the connection information is cleared upon closing the
application. One way to do this would be to add a custom property to the
currentproject object. Your code could then set this property after a user
has successfully logged on and retrieve the info upon startup.

I hope this helps,

Brian M. Sockey
www.farsightsolutions.com
 
I'm resending this since my last response didn't appear to go through...




Hi Svetlana,

The only way to do this would be to control the login process
programmatically. The SA user comes up because that is the account that
was likely used to create the initial connection for the ADP and so that
info is stored in the file's connection properties.

There are a couple of different steps to solving your problem. The first
is to use a custom logon form and perform the connection yourself using the
currentproject.openconnection method. This will replace any existing
connection info with that of the new connection info.

Secondly, for your own code to run without getting prompted by Access'
built-in login prompt, you will need to clear the connection info before
closing the application so that the app opens in a disconnected state the
next time around. This is done by passing a blank connection argument for
the openconnection method, as follows:

currentproject.openconnection ""

I usually hide the initial login form after I'm done with it and then have
this code run in the close event of the login form. The next time the app
is opened, your code can prompt the user for security credentials. However,
if you want to pre-populate the userid with the id of the last user, then
you will need to store and retrieve the data yourself because it will be
lost when the connection information is cleared upon closing the
application. One way to do this would be to add a custom property to the
currentproject object. Your code could then set this property after a user
has successfully logged on and retrieve the info upon startup.

I hope this helps,

Brian M. Sockey
www.farsightsolutions.com
www.televantagenorthwest.com
 
Hallo, Brian
thank you very much for your answer, it is an interesting
solution. I have tried it: my StartForm includs buttons
starting other forms of app; I made a pre-form and
wrote CurrentProject.OpenConnection "" into the close
event of it, as well as doCmd.OpenForm ("StartForm").
Now the same login-dialog with SA comes up as the first,
then my StartForm appears and eventually the error about
aborted connection. It seems to be too late in the pre-
form, which starts first in this app. What is wrong about
it? Thank you oncemore and look forward for your answer.
Svetlana
 
Your custom login form won't work right unless the connection property of
the ADP is blank when it was last closed. You will need to run the
CurrentProject.OpenConnection "" code at some point to clear this connection
and then restart your application. If your login form is set as the
startup form then your custom login form should appear. If you keep
getting the built-in Access security dialog when starting then you did not
properly clear the connection property before closing it.

This is exactly what the Microsoft developers had to do before shipping the
NorthwindCS.adp sample file. Otherwise, the ADP would try to connect to
whatever SQL Server the Microsoft developers were using before it got
shipped.

After running the line of code above just before shipping, the connection
property of northwindcs.adp is blank. When a user tries to open it later
on, the ADP opens in a disconnected state and code called from the autoexec
macro does it's magic to install the northwindcs database on SQL Serer and
connect to it.

Although your needs are much simpler, you are basically taking advantage of
the same technique.

I hope this helps,

Brian M. Sockey
www.farsightsolutions.com
www.televantagenorthwest.com
 
Back
Top