CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: access/ reports

  1. #1
    Join Date
    Apr 2001
    Posts
    60

    access/ reports

    I have a simple file server application that uses Ms Access and Vb. I have a general password on the database. My reports are in Access. Each time I want to view a report, I set up an application object for Access, then I use the OpenCurrentDatabase method to make the connection, then use the docmd to actually view it. The problem is that I am prompted for a password each time I want to see a report, even though I already was prompted for one when I opened my application. Here's my code:
    Set msaccess = New Access.Application
    msaccess.OpenCurrentDatabase (" path of database")

    msaccess.DoCmd.OpenReport "report name", acViewPreview
    DoCmd.Maximize
    msaccess.Visible = True

    I tried putting the password in the OpenCurrentDatabase statement,but it won't take it. There must be a way to do this because I am looking at the data report designer, and it's really goofy.


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: access/ reports

    Try to open your db as password protected

    For Standard Security:

    oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
    "Dbq=\somepath\mydb.mdb;" & _
    "Uid=Admin;" & _
    "Pwd=;"

    If you are using a Workgroup (System database):

    oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
    "Dbq=\somepath\mydb.mdb;" & _
    "SystemDB=\somepath\mydb.mdw;", _
    "admin", ""


    sConn = "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=" & DBPATH
    sConn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBPATH
    sConn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & DBPATH & ";uid=;pwd=;"

    'latest and greatest
    sConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & DBNAME & _
    ";Persist Security Info=False"
    Persist Security Info is important when db is password protected (False eliminate pwd protection?)

    '===================================================================
    'connection to secure database
    Dim Cnn As ADODB.Connection
    Dim Rst As ADODB.Recordset

    'In the place where you want to establish your connection, such
    'as the Initialize event of a class module, enter the following:

    Dim strConnect As String
    Set Cnn = New ADODB.Connection

    'Substitute your own User IDs, Password, Data Source, and System
    'database in the connection string below
    strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Password=MyPassword;User ID=Administrator;" & _
    "Data Source=C:\AccessDBs\DB1.mdb;" & _
    "Persist Security Info=True;" & _
    "Jet OLEDB:System database=C:\AccessDBs\system.mdw"

    With Cnn
    .CursorLocation = adUseClient
    .Open strConnect
    End With

    Set Rst = New ADODB.Recordset
    Rst.ActiveConnection = Cnn

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Apr 2001
    Posts
    60

    Re: access/ reports

    hi Iouri,
    thanks for the information. The problem is that I am using DAO. I tried to use the "persist security" option , but I can't get it to work.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured