Open Access from VB6

C

chris

Can I open Access from a VB6 program, define Access path, system path,
database path, user name & password for system.mdw ?

I tried the SHELL (code boew) and it works, but when I used it for opening
Excel, sometimes I was facing problems. Then I used the CREATEOBJECT and
everything is ok.

Dim var_process_number As Double 'return value for the window of pkzip.exe
Dim var_a As String

var_a = """" & "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" &
"""" & " "
var_a = var_a & "/wrkgrp" & " " & """" & "C:\System.MDW" & """" & " "
var_a = var_a & """" & "C:\My Programs\Open Access\aa1.mde" & """" & " "
var_a = var_a & " /user " & " " & """" & "db_admin" & """" & " "
var_a = var_a & " /pwd " & " " & """" & "" & """" & " "

var_process_number = Shell(var_a, vbMaximizedFocus)

For Access I tried to use CREATEOBJECT to create application, but it does
not allow me to change system.mdw path for defining mine with SystemDB
property. After command is executes, SystemDB still points to
"C:\WINDOWS\system32\system.mdw". Is there a solution to this ?

Dim AcApp As Access.Application

Set AcApp = CreateObject("Access.Application")
AcApp.DBEngine.SystemDB = "C:\System\System.MDW"
AcApp.DBEngine.DefaultUser = "db_admin"
AcApp.DBEngine.DefaultPassword = ""
AcApp.Visible = True
AcApp.OpenCurrentDatabase cDatabaseToOpen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top