Paths to files

hojkoff

Registered User.
Local time
Today, 00:58
Joined
Sep 1, 2009
Messages
16
I've written up a code to open pdf files when buttons are clicked on a forum but I'm having trouble with the paths.

I have to burn the access file and all the pdf files to disc so that the disc can be handed round at the office when it's needed. My problem is that when writing the program I've linked all the files to the pdfs stored on the local disc (just to get stuff working and then tackle this problem later/now.)

How can I change my code so that the paths are "relative ," if you like to the location that the access database is stored?

Thanks guys! :D
 
Last edited:
How can I change my code so that the paths are "relieve," if you like to the location that the access database is stored?

Thanks guys! :D

Relative is the word your looking for, see below function
Code:
Function myFolder()
    myFolder = Left(CurrentDb.Name, InStrRev(CurrentDb.Name, "\"))
End Function

Note that an Access DB will not work on a CD-rom due to the creation of the ldb file upon opening
 
Relative is the word your looking for, see below function
Code:
Function myFolder()
    myFolder = Left(CurrentDb.Name, InStrRev(CurrentDb.Name, "\"))
End Function

I'm prety confused about how to make this line of coding work,

My database is called "Box Data Base Complete"
so I take it that the code would be writen,

Code:
Function myFolder()
myFolder = Left(Box Data Base Complete.Name, InStrRev(Box Data Base Complete.Name, "THE LOCATION THAT ITS STORED AT I'M REALLY NOT SURE WHAT TO PUT HERE WHERE YOU HAVE A \"))
End function

Are these the only lines that I need to add or do I have to call this everytime I want a path to a pdf?

I have all this at the moment,

Code:
acrobatApp = "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32 C:\Documents and Settings\Andrew*.***\Desktop\*** Bridge Drawing Register\Drawings\1124\1244-"
...
...
  Set Inset = thisQuery.OpenRecordset()
  If Inset.RecordCount > 0 Then
      Inset.MoveFirst
      docName = Inset![Canliver Brackets (West) dwg]
      cmdLine = acrobatApp + docName
      procID = Shell(cmdLine, vbNormalFocus)

What do I change it to?

Note that an Access DB will not work on a CD-rom due to the creation of the ldb file upon opening

The database is not to be edited by anyone else.
 
Last edited:
Just use the function as is... myFolder will return the folder the current database is, regardless of its name...

This is assuming the PDFs are somewhere related to the database... If the PDFs are always on C:\Someplace you wouldnt need to alter the path right??
 
The database is for a bridge which is split into 80 boxes (as it is a box girder bridge) each box has 8 cantilevers attached to it. Each cantilever has it's own reference number and it's own drawing to go with it which are all in pdf now. I've taken ages entering all this information into a table. My database has a forum with a combobox on it with 1 to 80 in it. When you select a number the VBA code queries the table for that box number. The drawing number is related to the path. When you click on the cantilever reference number the drawing pops up.

ie. Box 6, cantilever ref (for example) 89 will be stored in file 345b.pdf however for Box 72 the file may be 152g.pdf so the path is constantly updating as you click around the combo box.

All the pdf files and the database are burnt to a DVD so that when I send the DVD down to for example the London office they can open it and it'll work.

This is why I have to have the VBA code reference the path on the DVD and not the one that I have entered above.

So from what you're saying if I type in

Code:
[COLOR=black][FONT=Verdana]Function myFolder()[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]   myFolder = Left(CurrentDb.Name, InStrRev(CurrentDb.Name, "\"))[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]End Function[/FONT][/COLOR]

at the top of my VB code, it'll all work?

I take it that this line will have to include the myFolder variable although I'm not 100% how to fit it into this line,

Code:
acrobatApp = "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32 C:\Documents and Settings\Andrew*.***\Desktop\*** Bridge Drawing Register\Drawings\1124\1244-"
 
Last edited:
Past3e my function into a VBA window, then go to the immediate window (CTRL + G, if you dont know it) and type: ?myFolder

You will find it returns a full path of where the database is, i.e. C:\Temp\

Now if the PDFs are on C:\PDF you can use:
"C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32 " & myfolder & "..\PDF\" & YourFileName

The .. in case you dont know goes up one folder.

Now... If the PDFs are in C:\Temp\PDF you use
"C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32 " & myfolder & "PDF\" & YourFileName

More Clear?
 

Users who are viewing this thread

Back
Top Bottom