omarrpa,[ol]
[li]Browse for a file:[ul]
[li]If your using Access 2002 or newer look at the [tt]FileDialog[/tt] class (you may need to add a reference to the Microsoft Office x.x Object Library).[/li]
[li]If your using Access 2000 or older you will need to use an API, search for [tt]GetOpenFileName[/tt] in this forum.[/li][/ul][/li]
[li]Once you use one of the above you can convert the filename to a Hyperlink and store in your table.[/li][/ol]
I created a form connected to a table with a hyperlink field. I created a command button and an unbound listbox. The following specifies a specific path as seen next to Dir$.
Go to design view of the form. Click on the command button. Click on the property button. Click on the Event Tab. Click in the box next to OnClick. Click on the button with the three dots. Select Code Builder.
Copy: (Sub and End Sub statements are already there)
Private Sub Command0_Click()
Dim LoadFiles As String
Dim strFill As String
LoadFiles = Dir$("c:\excelforcourse\*.*")
Do While LoadFiles > ""
strFill = strFill & LoadFiles & ";"
LoadFiles = Dir$
Loop
Me![1stFiles].RowSource = strFill
End Sub
On the AfterUpdate of the listbox (see above directions to place code), I placed:
Private Sub Ctl1stFiles_AfterUpdate()
Dim holdname As String
holdname = "#c:\excelforcourse\" & Me![1stfiles] & "#"
Me![hype].Value = holdname
End Sub
Me![hype] is the name of the hyperlink field.
Me![1stFiles] is the name of the listbox.
Note you need the # # signs around the path name.
They can now save the selection and it'll also open the file if clicked on.
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.