Solved

VB Access 2000 Passwords

Posted on 2002-06-28
7
320 Views
Last Modified: 2010-05-02
I am trying to connect to a Access .db with a global password.

 TMRace = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & dbFile & ";UID=Administrator;PWD=sam1104;"
        conn.Open TMRace

When I try to compact it after closing the above connection I get an error with the following code:

 Dim strSourceDB As String
 Dim strDestDB As String
 
  Dim jetEngine          As JRO.jetEngine
  Dim strSourceConnect   As String
  Dim strDestConnect     As String
 strSourceDB = dbFile
 strDestDB = dbArchive
 
 Kill (dbArchive)
 
  strSourceConnect = "Data Source=" & strSourceDB & ";"
  strDestConnect = "Data Source=" & strDestDB & ";"

  Set jetEngine = New JRO.jetEngine

  jetEngine.CompactDatabase strSourceConnect, strDestConnect

  Set jetEngine = Nothing
  CompactDb = True
End Function

What is the proper syntax for this compact with the first connect string?  Ideas?

dmoring
0
Comment
Question by:dmoring
  • 4
  • 3
7 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 7117897
Compact Database Example.

Dim objDAO_DBEngine As Object
Dim objFSO As Object
Dim strCompactedDBFile As String

Set objDAO_DBEngine = CreateObject("DAO.DBEngine.36")
Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FileExists(strCompactedDBFile) Then
   objFSO.DeleteFile (strCompactedDBFile)
End If

objDAO_DBEngine.CompactDatabase dbFile, dbArchive

objFSO.CopyFile dbArchive, dbFile

objFSO.DeleteFile dbArchive 'delete the copy

Set objFSO = Nothing
Set objDAO_DBEngine = Nothing



hongjun
0
 
LVL 33

Expert Comment

by:hongjun
ID: 7117899
Ignore the above post. Got some errors. Below is the correct example.



Dim objDAO_DBEngine As Object
Dim objFSO As Object
Dim strCompactedDBFile As String

Set objDAO_DBEngine = CreateObject("DAO.DBEngine.36")
Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FileExists(dbArchive) Then
  objFSO.DeleteFile (dbArchive)
End If

objDAO_DBEngine.CompactDatabase dbFile, dbArchive

objFSO.CopyFile dbArchive, dbFile

objFSO.DeleteFile dbArchive 'delete the copy

Set objFSO = Nothing
Set objDAO_DBEngine = Nothing



hongjun
0
 
LVL 33

Expert Comment

by:hongjun
ID: 7117901
dmoring, you have few opened questions yet to be closed. Please maintain them.

hongjun
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:dmoring
ID: 7117948
hongjun,
There is a way with existing VB objects - not creating new instances as in ASP.  Also, I have a password on this one.

Other ideas?

Re: Unclosed questions - Did not get solution 2 of the 4 but closed them anyway and awarded points to the best answer.  The other 2 are this one and one with points for someone who has yet to pick them up. Thanks for the reminder though.

dmoring
0
 
LVL 33

Accepted Solution

by:
hongjun earned 100 total points
ID: 7117984
Try this

Try this

Dim jetEngine As JRO.JetEngine
Dim strSourceConnect As String
Dim strDestConnect As String
Dim objFso As Object

Set jetEngine = New JRO.JetEngine
strSourceConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                 "Data Source=" & dbFile & ";" & _
                 "User Id=Administrator;" & _
                 "Password=sam1104;"
strDestConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
             "Data Source=" & dbArchive & ";" & _
             "User Id=Administrator;" & _
             "Password=sam1104;"

jetEngine.CompactDatabase strSourceConnect, strDestConnect

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile dbArchive, dbFile
objFSO.DeleteFile dbArchive 'delete the copy


Set objFSO = Nothing
Set jetEngine = Nothing


hongjun
0
 

Author Comment

by:dmoring
ID: 7118417
Now you're onto my problem :-).  With that It wants a workgroup file to pull the username/id from the system.mdw and I just want an overall password for the .db - NOT a user workgroup setup.  If I put it in exactly as you describe (already did it - should have told you), I get the error 'Could not find WorkGroup file', which is correct.  I don't have the .db set up for tiered-access - just an overall password.

Keep going - your on the right track!

dmoring
0
 

Author Comment

by:dmoring
ID: 7118466
Got it!  It was:
        'Set Connect Strings
        strSourceConnect = "Data Source=" & dbFile & ";" & _
                            "Jet OLEDB:Database Password=sam1104;"
        strDestConnect = "Data Source=" & dbArchive & ";" & _
                            "Jet OLEDB:Database Password=sam1104;"
        strTempConnect = "Data Source=" & dbTemp & ";" & _
                            "Jet OLEDB:Database Password=sam1104;"

without Database in front of password, it is looking for the workgroup information - NOT the overall password.  Thanks for your effort and prompt response though!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we 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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now