I am currently using access 2000. What I want to do is click the command button (in the form) that will let the user to open a file or insert the selected file into a list box. Or even select a file and put it in a list box as a hyperlink. Any suggestions would be appreciated.
API coding can be a pain if you don't know about it, here, try this simple code, just have to add a COMMON DIALOGS CONTROL on your form :
'Insert a COMMON DIALOGS CONTROL on your form
'Name it "CommonDialog1"
'Create a button and use that code
CommonDialog1.FileName = ""
If CommonDialog1.FileName & "" = "" Then
MsgBox "No file selected"
MsgBox "File selected: " & CommonDialog1.FileName
What do you mean by Hyperlink? You can use the property IsHyperlink, but it will only show the text as being hyperlink, if you want to open the file on a click of the textbox, you can use ShellExecute API:
Private 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 Long) As Long
Private Sub Texte1_Click()
ShellExecute 0, "open", Me.Texte1, "", "", 0
You can use another event than click (mouse up), since it is pretty confusing to click a textbox and see a new window appears, is that what you wanted?
What i want to do is, once I click on the command button, and the "open file" box appears (for the user to open/select a file), I want the selected file to not open, but to be hyperlinked into a textbox.
Basically, I am putting a common dilog box not on the form to open or save, but, to put a hyperlink of the selected file into the text box.
How can I do that?
So far, all that happens once I click on the command button is that the open file box appears and once I select a file, it sais "file selected: c:\mydocuments\balh\blah" - But thats all that happens. just a message. I would like for the selected file to be a hyperlink into a specific textbox.