Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2002
    Posts
    79

    Unanswered: file open dialogue box

    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.

  2. #2
    Join Date
    Jul 2002
    Location
    Romania
    Posts
    122
    Check this link for the Open/Save dialog:

    http://www.mvps.org/access/api/api0001.htm

    Good luck

    Dan

  3. #3
    Join Date
    Sep 2002
    Posts
    79
    Originally posted by DannyY
    Check this link for the Open/Save dialog:

    http://www.mvps.org/access/api/api0001.htm

    Good luck

    Dan


    I'm sorry but I really cant make sense of that site (I'm not as advanced). It doesnt really explain where the codes go, do i need a button...etc.

    Any additional help would be greatly appreciated

  4. #4
    Join Date
    Jul 2002
    Location
    Romania
    Posts
    122
    Paste everything in a new module in your database.
    Save the module
    Place a button in your form
    Right click the button
    Choose Build-Code Builder

    It will take you to the Click event of the button.

    Type:

    Dim varStr As String
    varStr = GetOpenFile()
    MsgBox = varStr



    that's all, you have stored the result of the Open Dialog into a variable and you can use it as you want

    Regards,

    Dan

  5. #5
    Join Date
    Aug 2002
    Location
    Québec, Canada
    Posts
    109
    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 :

    Code:
        'Insert a COMMON DIALOGS CONTROL on your form
        'Name it "CommonDialog1"
        'Create a button and use that code
        
        CommonDialog1.FileName = ""
    
        CommonDialog1.ShowOpen
        
        If CommonDialog1.FileName & "" = "" Then
            MsgBox "No file selected"
        Else
            MsgBox "File selected: " & CommonDialog1.FileName
        End If
    JefB - hope it helps

  6. #6
    Join Date
    Sep 2002
    Posts
    79
    Tanks JefB.

    How can I get the file selected to be hyperlinked into a text box?
    Last edited by alex8111; 09-27-02 at 16:46.

  7. #7
    Join Date
    Aug 2002
    Location
    Québec, Canada
    Posts
    109
    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:

    Code:
    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
    End Sub
    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?

    JefB

  8. #8
    Join Date
    Sep 2002
    Posts
    79
    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.

    Any help would be greatly appreciated.

  9. #9
    Join Date
    Aug 2002
    Location
    Québec, Canada
    Posts
    109
    you can remove the Message Box (or change it) as you wish, it is just to show that the FileName is accessible like that:

    CommonDialog1.FileName

    So, you can use:

    'txtFileName is a textbox
    txtFileName.Value = CommonDialog1.FileName

    JefB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •