Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a database from a database... AND include the workgroup file???

Status
Not open for further replies.

snoopy75

Technical User
Aug 24, 2001
340
US
Alright, I need to open another database from my VB code, but I need to specify the workgroup file in the call. I do know that the command-line prompt for what I want to do goes like this:
Code:
"C:\Program Files\Microsoft Office\Office\MSAccess.exe" "C:\Database\Database.mdb" /wrkgrp "\\hif-fslao-11\Equipment\Database\Workgroup.mdw"
I've been trying to work with the ShellExecute API function, but I can't seem to get it to work. Here's my latest attempt:
Code:
retval = ShellExecute(Application.hWndAccessApp, "open", "C:\Database\Database.mdb", "/wrkgrp '\\hif-fslao-11\Equipment\Database\Workgroup.mdw'", "C:\Database", 1)
This seems to get me into my database alright, but it's not using the workgroup file I specify. Could someone help me with the syntax? Or tell me another way to do this? Thanks in advance. :)
 
This was in the help:

Sub AccessDDE()
Dim intChan1 As Integer, intChan2 As Integer
Dim strQueryData As String

' Use System topic to open Northwind sample database.
' Database must be open before using other DDE topics.
intChan1 = DDEInitiate("MSAccess", "System")
' You may need to change this path to point to actual location
' of Northwind sample database.
DDEExecute intChan1, "[OpenDatabase C:\Access\Samples\Northwind.mdb]"

' Get all data from Ten Most Expensive Products query.
intChan2 = DDEInitiate("MSAccess", "Northwind.mdb;" _
& "QUERY Ten Most Expensive Products")
strQueryData = DDERequest(intChan2, "All")
DDETerminate intChan2

' Close database.
DDEExecute intChan1, "[CloseDatabase]"
DDETerminate intChan1

' Print retrieved data to Debug Window.
Debug.Print strQueryData
End Sub

Probably a very poor way of doing it though. Hope this is ok. If not, just let me know.

Nick (Everton Rool OK!)
 
Hmm... if I understand correctly, the example you've provided merely retrieves data from another database using Automation. What I want to do, specifically, is close and re-open the same database. Any ideas there?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top