Hi there,
I want to open a database from a macro in another database and I have it working, except that we have usernames and passwords to log on, so when the macro is run is automatically asks for a username and password.
I've tried entering the conditions as follows:
'Open the External Database in Access Window
appAccess.OpenCurrentDatabase strDBPath, False, bstrPassword
providing it with the database path (as String), that I don't need to enter the database exclusively, and finally providing it with my password (as String). However, it doesn't pick up the password. However, once I key it in manually, it will continue running correctly till completion.
I would appreciate if somebody could let me know is it possible to automate this, so that I could open the database etc. without having to manually enter the password?
Thanks in advance.
8 3759
Hi there,
I want to open a database from a macro in another database and I have it working, except that we have usernames and passwords to log on, so when the macro is run is automatically asks for a username and password.
I've tried entering the conditions as follows:
'Open the External Database in Access Window
appAccess.OpenCurrentDatabase strDBPath, False, bstrPassword
providing it with the database path (as String), that I don't need to enter the database exclusively, and finally providing it with my password (as String). However, it doesn't pick up the password. However, once I key it in manually, it will continue running correctly till completion.
I would appreciate if somebody could let me know is it possible to automate this, so that I could open the database etc. without having to manually enter the password?
Thanks in advance.
The Password that you are referring to is the Database Password, not the Password associated with the UserName/Password combination seen in Access security Models. That is why entering it as an Argument in the OpenCurrentDatabase() Method had no effect.
Thanks for this. However, I still would appreciate if somebody could let me know if it's possible to automatically override the username and password of the database I am opening, or to code the username and password, so the function can be run automatically?
Thanks.
Thanks for this. However, I still would appreciate if somebody could let me know if it's possible to automatically override the username and password of the database I am opening, or to code the username and password, so the function can be run automatically?
Thanks.
There are several Methods of automating the process of entering a Database's Password but the User Name and Password is another problem. You could try SendKeys by placing certain Keystrokes in the buffer, then inserting them at the proper time, but this would be a little hairy to say the least. I'll look into it further for you.
There are several Methods of automating the process of entering a Database's Password but the User Name and Password is another problem. You could try SendKeys by placing certain Keystrokes in the buffer, then inserting them at the proper time, but this would be a little hairy to say the least. I'll look into it further for you.
If both databases are using the same MDW and you are moving from one to the other with the same username, you should not need to specify passwords as you are already logged on to the MDW
If you are using different MDW's or different usernames and passwords you could try looking at the help for
because I see that lets you specify connect info such as MDW, username, password.
I use DBEngine.CreateWorkspace a lot to change to a hidden secure user for certain functions, and I think the OpenDatabase method is the way to go.
I can't be more help as I have not needed to do this myself.
If both databases are using the same MDW and you are moving from one to the other with the same username, you should not need to specify passwords as you are already logged on to the MDW
If you are using different MDW's or different usernames and passwords you could try looking at the help for
because I see that lets you specify connect info such as MDW, username, password.
I use DBEngine.CreateWorkspace a lot to change to a hidden secure user for certain functions, and I think the OpenDatabase method is the way to go.
I can't be more help as I have not needed to do this myself.
I think I found one solution to your dilemma, and it involves specifying the User ID and Passwords as properties of the ADODB Connection Object. The following code will open the Test.mdb Database in the C:\Test Directory, then loop through all Records in tblEmployees printing the First and Last Names. I've tested it on an Unsecured Database and it works fine. Make the necessary substitutions, and attempt to open your External, Secured, Database and see what happens. Please get back to me on this one, I'm curious myself as to the outcome. Good Luck! -
Dim cnn As ADODB.Connection
-
Dim rst As ADODB.Recordset, strPathToExternalDB As String
-
-
strPathToExternalDB = "C:\Test\Test.mdb"
-
-
Set cnn = New ADODB.Connection
-
Set rst = New ADODB.Recordset
-
-
cnn.Provider = "Microsoft Jet 4.0 OLE DB Provider"
-
cnn.ConnectionString = "Data Source = " & strPathToExternalDB
-
cnn.Properties("User ID").Value = "Admin" 'unsecured database
-
cnn.Properties("Password").Value = "" 'unsecured database
-
cnn.Open
-
-
With rst
-
.Source = "tblEmployees"
-
.ActiveConnection = cnn
-
.CursorType = adOpenKeyset
-
.LockType = adLockOptimistic
-
.Open
-
End With
-
-
rst.MoveFirst
-
Do While Not rst.EOF
-
'do whatever processing you need to do here
-
Debug.Print rst![FirstName] & " " & rst![LastName]
-
rst.MoveNext
-
Loop
-
-
rst.Close
-
cnn.Close
-
Set rst = Nothing
-
Set cnn = Nothing
-
Hi there,
Well after much playing around, I'm afraid I cannot get passed the error message at cnn.open:
Run-time Error ....
Cannot Start your application. The workgroup information file is missing or opened exclusively by another user.
But thanks a million for all your help with this matter, it's much appreciated and if you do have any other suggestions let me know.
Thanks.
Hi there,
Well after much playing around, I'm afraid I cannot get passed the error message at cnn.open:
Run-time Error ....
Cannot Start your application. The workgroup information file is missing or opened exclusively by another user.
But thanks a million for all your help with this matter, it's much appreciated and if you do have any other suggestions let me know.
Thanks.
Cannot understand why you getting this Error Message if the Database is not opened Exclusively by another User. When I get the chance, I'll try the code on a secured Database.
Hi there,
Well after much playing around, I'm afraid I cannot get passed the error message at cnn.open:
Run-time Error ....
Cannot Start your application. The workgroup information file is missing or opened exclusively by another user.
But thanks a million for all your help with this matter, it's much appreciated and if you do have any other suggestions let me know.
Thanks.
I am happy to report that I finally solved the problem. You must explicitly specify the location of the System Database in the "Jet OLEDB:System database" Property of the Connection Object (just add Line #14). The following code will Open the Northwind.mdb Database in the C:\Dell\ Directory using the C:\Dell\ADH.MDW System Database. The User ID and Password are programmatically supplied. Good luck - any other questions feel free to ask. I going to relax now, since this one really taxed my brain: -
Private Sub Command7_Click()
-
Dim cnn As ADODB.Connection
-
Dim rst As ADODB.Recordset, strPathToExternalDB As String
-
-
strPathToExternalDB = "C:\Dell\Northwind.mdb"
-
-
Set cnn = New ADODB.Connection
-
Set rst = New ADODB.Recordset
-
-
cnn.Provider = "Microsoft Jet 4.0 OLE DB Provider"
-
cnn.ConnectionString = "Data Source = " & strPathToExternalDB
-
cnn.Properties("User ID").Value = "Paul" 'secured database
-
cnn.Properties("Password").Value = "Paul" 'secured database
-
cnn.Properties("Jet OLEDB:System database") = "C:\Dell\ADH.MDW"
-
cnn.Open
-
-
With rst
-
.Source = "Employees"
-
.ActiveConnection = cnn
-
.CursorType = adOpenKeyset
-
.LockType = adLockOptimistic
-
.Open
-
End With
-
-
rst.MoveFirst
-
Do While Not rst.EOF
-
'do whatever processing you need to do here
-
Debug.Print rst![FirstName] & " " & rst![LastName]
-
rst.MoveNext
-
Loop
-
-
rst.Close
-
cnn.Close
-
Set rst = Nothing
-
Set cnn = Nothing
-
End Sub
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Lobang Trader |
last post by:
Hi all,
I am trying to create a username and a password class.
I would like to know what are the RECOMMENDED minimum and maximum length
for both fields?
These fields will be something like...
|
by: Matt |
last post by:
Hiya
I have to develop a web application for my company in
which I need to have a facility for username and password
for the employees to do certain tasks. How can this be
implemented in ASP. I...
|
by: Kevin O'Brien |
last post by:
Hello,
I am creating a sign on screen for my application in which I want to store
the username and password in a database table. I was thinking of putting a
combo box connected to the database...
|
by: gujarsachin2001 |
last post by:
hello friends
i m connecting to http or https url programatically through console
application using follwoing methods of credentilas but if there is
username & password for that url through this...
|
by: Hooyoo |
last post by:
Hi, here.
I write following codes:
string password = Console.ReadLine();
I want users enter their passwords, but readline will show content of
password when entering, so is there any way to...
|
by: sanbm79 |
last post by:
Hi All,
I am facing a problem in posting Web request with username and password
credentials.
I am working on migrating Java client application to .Net which will send
request to Java servlet.
...
|
by: libra786 |
last post by:
I have created a blog and have added a login box which prompts the user for login and id before posting- The username and password have been stored in the database, however when i enter the username...
|
by: patelxxx |
last post by:
Guy's,
I'm using the following code and before I even enter my username and password I get the following error: 'Username or password did not match', what I'm I doing wrong?
my $session =...
|
by: rodrigo |
last post by:
I am trying to retrieve a password protected page using:
get = urllib.urlopen('http://password.protected.url"').read()
While doing this interactively, I'm asked for the username, then the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |