Solved

Opening an Access97 object that requires password

Posted on 1998-08-04
10
284 Views
Last Modified: 2010-08-05
Hi,

I want my VB application to open an access97 instance. I need this to be done without any user interaction,
The problem is that opening the database requires login and password, so when I'm creating the new access
instance, it first opens a login screen and wait.

Is there a way that I can automatically insert the login/password without user interaction?

Thanks
0
Comment
Question by:yronnen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 1

Expert Comment

by:SeanGiles
ID: 1467704
Create a workspace rather than using the default one and set the username and pwd when you create it.
Dim wk As Workspace
Dim db As Database

Private Sub Form_Load()
    Set wk = CreateWorkspace("test", "Admin", "Admin", dbUseJet)
    Set db = wk.OpenDatabase("nwind.mdb")
End Sub

0
 
LVL 5

Author Comment

by:yronnen
ID: 1467705
SeanGiles,
I do not want to open a mdb file using DAO. I want to open Access97 ITSELF using set Acc=New Access.Application
0
 
LVL 3

Expert Comment

by:SPECIALIST
ID: 1467706
Windows API/Global Declarations for :automatic password logon to ACCESS  database
'****************************************************************


Declare Function Wnetgetuser Lib "mpr" Alias "WNetGetUserA" (ByVal lpName
       As String, ByVal lpUserName As String, lpnLength As Long) As Long



Public Function NetWorkUser() As String

       Static strUser As String

              If Len(strUser) Then
                      NetWorkUser = strUser
                      Exit Function
              End If

       Dim lpUserName As String * 64

              If Wnetgetuser("", lpUserName, Len(lpUserName)) Then
                      strUser = CurrentUser()
              Else
                      strUser = Left(lpUserName, InStr(lpUserName, Chr(0)) - 1)
              End If

       NetWorkUser = strUser
       
End Function

After you write the code to create your database, use this code to automatically log you on.

David
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Author Comment

by:yronnen
ID: 1467707
Sorry SeanGiles,
You told me how to get the user details from the registry. this is not my question...so I'll clarify my question:
I KNOW the user details, I know everything. What I need to do is to programmatically send a report to a printer using VB code.

To do that I need to start an access instance, open the DB and print the report. I know how to do that, too.

What I DON'T know is how to send the database login/password, so when Access starts, it will not prompt me for login.
0
 
LVL 9

Expert Comment

by:cymbolic
ID: 1467708
You can start access and pass in your database, user and password parameters on the command line.  You can also invoke a start up macro as well from the comand line, and have the macro run your report.  You can do this via the shell command, or via WIN32 API commands.  This will allow you to have Access run your report starting it from VB.
0
 
LVL 5

Author Comment

by:yronnen
ID: 1467709
cymbolic,
Your answer forces me to have an autoexec macro. I don't know which database will the user open, so it's not good for me.

I need to open access as an activex server.
0
 
LVL 4

Expert Comment

by:tomook
ID: 1467710
I know this does not help, but I wrestled with this for a long time and gave up. The only way to get the user name and password automatically to Access seems to be on the command line, and how do you do that in a New or CreateObject? I would really like to see someone come up with an answer to this one.
0
 
LVL 1

Expert Comment

by:soeding
ID: 1467711
tomook,
if nothing else is working,
try SendKeys
0
 
LVL 4

Expert Comment

by:tomook
ID: 1467712
The trick with SendKeys is getting a handle to the login window. For some reason we could not reliably get one. It sometimes worked and sometimes not.
0
 
LVL 1

Accepted Solution

by:
raygibbins earned 50 total points
ID: 1467713
I set up an Access DB, set the password to "Password", I haven't tried yet with User name - but try this first.

Note no error handling

Private Sub Form_Load()
Dim acc As Object
Set acc = CreateObject("Access.application")
With acc.application
    SendKeys "Password{Enter}", False
    .OpenCurrentDatabase "c:\estate\office.mdb"
    .DoCmd.OpenReport "Report1", acNormal, "", ""
End With
Set acc = Nothing
End
End Sub

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
String manipulation in Visual Basic 7 82
Saving history changes to sub form 4 51
TT Auto Dashboard 13 100
Macro problems with Excel file 6 22
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question