Opening files in Access

By dlester ·
Ok here's what I've got. We've designed a database for our engineering staff to use to keep track of open projects and the like for themselves. What we have is a simple Access 2000 format database, with a few very simple macros and queries. What I can't figure out is a way for Access to open up the drawing files from the table when a query is ran. For example, say an engineer pulls up the query CAD drawings button, which runs a query for them on the Key Field of the central Table, and pulls up a person who has four different drawings. What I want them to be able to do is to be able to double-click the drawing number, and for access to open the file in the CAD software based on the drawing number. I know it can be done, a previous programmer did it for an older drawing database, but I can't get his code to work either right now. Any Ideas??

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

You want the ShellExecute API

by Tony Hopkinson In reply to Opening files in Access
Collapse -

Good idea!

by dlester In reply to You want the ShellExecute ...

Ok, so how can I use this code to make it open the specific file that's in the query?

Collapse -


by Tony Hopkinson In reply to Good idea!

pop this waffle at the top of the form code.

Public 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 Integer) As Long

How you want to do the UI is much of a muchness. but one way would be to add a button "View Drawing" then in it's commnd? (I'm a bit out of date in access)


Hope this helps

PS If you have a file association set up for the drawing files to your cad software.


Means you don't have to hard code where CAD is installed.

Above assumes drawingfilename from the query has the extension in it, otherwise you'll have to bolt that on say DrawingFileName + ".CAD"

Also if drawingfilename happens to be the full path, you don't need teh start directory, that though means a bit of messing about if you ever relocate your drawing files.

Related Discussions

Related Forums