front end directory. I am using the edit hyperlink macro action. Is there
some way to modify the EditHyperlink command to default to open at the
back
end directory?
I have been looking for that in the past, but haven't been able to find it.
I have looked up some of my old code, that doesn't use the hyperlink
browser, but the filedialog browser. It opens in the Hyperlink base folder
and it translates the selected file into a value the hyperlinkfield needs.
fldFilename is the hyperlinkfield in the form based on the hyperlink table.
For the filedialog to work you need to set the reference 'Microsoft Office
XX.0 Object Library'.
Maybe you can put it to use.
Private Sub btnChoose_Click()
Dim fDialog As Office.FileDialog
Dim strHypFldr As String
Dim strFullPath As String
On Error GoTo Err_Handler
strHypFldr = fgPathApp & "Hyperlinks\" 'fgPathApp is a global var
directing
to the Hyperlink base folder
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.AllowMultiSelect = False
.Title = "Select a file"
.Filters.Clear
.Filters.Add "All files", "*.*"
.Filters.Add "MS Word", "*.doc"
.Filters.Add "MS Excel", "*.xls"
.Filters.Add "Text", "*.txt"
.Filters.Add "Outlook mail", "*.msg"
.Filters.Add "PDF", "*.pdf"
.Filters.Add "JPEGs", "*.jpg"
.FilterIndex = 1
.InitialFileName = strHypFldr
If .Show = False Then
Exit Sub
Else
strFullPath = .SelectedItems(1)
If Len(strFullPath) >= Len(strHypFldr) Then
If Left(strFullPath, Len(strHypFldr)) = strHypFldr Then
fldFilename = Right(strFullPath, Len(strFullPath) -
Len(strHypFldr)) & "#" & Right(strFullPath, Len(strFullPath) -
Len(strHypFldr)) & "#"
Else
fldFilename = strFullPath & "#" & strFullPath & "#"
End If
Else
fldFilename = strFullPath & "#" & strFullPath & "#"
End If
End If
End With
Exit_Point: Exit Sub
Err_Handler:
If Err.Number <> 2501 Then
MsgBox Err.Description, vbExclamation, "Error " & Err.Number
End If
Resume Exit_Point
End Sub
John
kharpe said:
Your post on the hyperlink base will come in useful for migration
purposes. I
will be able to use a variation on it to allow for the user to move the
backend and photos without having to relink them every time.
I was hoping to find a way to save the user some time when linking a file
though. At the moment, when a hyperlink is linked, a browser window is
opened. The directory that the window displays is the current directory
(directory with the front end). I am planning on having the front end on a
local computer and the back end on a server. I would like to have the
browser
window default to open to the current back end directory rather than the
front end directory. I am using the edit hyperlink macro action. Is there
some way to modify the EditHyperlink command to default to open at the
back
end directory?
Thanks again
John J. said:
Sorry, I missinterpreted your question. The code is meant to set the
Hyperlink base folder programmatically (File-Database properties).
The hyperlink browser opens in the folder where the mdb resides. If you
choose files from here, the whole path will be stored, which probably is
not
what you want. However, if you press the button with the open folder with
arrow on it, right next to globe button, the Hyperlink base folder will
show
at once. If you choose files in this way only the part of the path that
comes after the Hyperlink base folder willl be stored, which will make
migration of the data easy.
You could ofcourse write vba code to open the standard filebrowser in
your
default folder and store the selected value in your table. I recall
reading
some posts from MVP who gave up on the hyperlink field entirely and just
store the path and file name in a text field and have code open the
files.
John
kharpe said:
I tried putting this in to my code, the edit hyperlink still opens the
browser in the folder with the front end, not the back end.
:
You can set the default hyperlink location to any folder you like.
This
example does this by retrieving the first part of the folder's name
from
a
control
table and adding the "Hyperlinks\" folder. It uses Allen Browne's
Dlookup
alternative, Elookup.
Public Function fSetHyperlinkBase()
Dim db As DAO.Database
Dim doc As DAO.Document
Dim prp As DAO.Property
Dim varLU As Variant
On Error GoTo Err_Handler
varLU = ELookup("[Control_text]", "tbControl", "[Control_description]
=
'Path_to_app'")
If IsNull(varLU) Then
MsgBox ("Critical error. The hyperlink path cannot be found.")
Exit Function
Else
Set db = CurrentDb
Set doc = db.Containers("Databases").Documents("SummaryInfo")
Set prp = doc.Properties("Hyperlink base")
varLU = varLU & "Hyperlinks\"
prp = varLU
End If
Exit_SetHyperlinkBase:
Set prp = Nothing
Set doc = Nothing
Set db = Nothing
Exit Function
Err_Handler:
If Err.Number = 3270 Then ' property not found
Set prp = doc.CreateProperty("Hyperlink base", dbText, varLU)
doc.Properties.Append prp
Resume Next
Else
MsgBox Err.Description, vbExclamation, "Error " & Err.Number
Resume Exit_SetHyperlinkBase
End If
End Function
John
"kharpe" <
[email protected]> schreef in bericht
I have a split database in Access 2007. One of the tables in my
backend
stores hyperlinks. The hyperlinks are edited using the edithyperlink
macro
action. When the file browser opens, the default location is the
directory
that contains the front end. I was wondering if there is a way to
have
the
default location be the back end directory?
Thank you for your assistance