Without creating a connection or anything, all I want to do is open a certain Access 97 file with VB. Is there a siple way to do this? ( I only need to open the file, not make any chages to it )
There are 2 ways to use an access db in vb:
1) You create a connection to the database. you don't have to use DSN, you can connect to it directly.
2) Otherwise, you can open it using an access object:
Dim objAccess As Access.Application
Set objAccess = CreateObject("Access.Application"
.
.
.
Set objAccess = Nothing
Chi Happens
"When you know and respect your own inner nature, you know where you belong. You also know where you don't belong" - Benjamin Hoff
Slonoma,
Two things. One is that if you use the second method that ChiHappens suggested, make sure that you go to Project-References and add a reference to a Microsoft Access Object Library. And the second is that if you just want to open an instance of Access with that file, you can just use:
shell("filename.mdb"
Which will open the file with it's default application which in this case will be access.
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'People who live in windowed environments shouldn't cast pointers.'
Thanks for the help. I decided to go with the Shell, however just the simple Shell would not work for some reason. I had to use the ShellExecute and add the corresponding reference. I found this in a thread but I do not remember which one..Something like this:
'General Declarations....
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation _
As String, ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
'And when opening the file....
tempNum = ShellExecute(hWnd, vbNullString, "C:\FOLDER\DATABASEFILE.mdb", vbNullString, vbNullString, vbNormalFocus)
Thanks again.
Chris
"You can't steal second with your foot on first base."
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.