Results 1 to 1 of 1
  1. #1
    Join Date
    Oct 2005
    Posts
    183

    Unanswered: Inserting and opening Hyperlinks

    I'm having some issues with a smal database of mine, that has a table with paths / files of documents related to a given record.

    Using the code:
    Code:
        Dim fd As FileDialog
        Dim filen As String
        Dim valg As Integer
        Dim sql As String
             
        Set fd = Application.FileDialog(msoFileDialogFolderPicker)
        fd.InitialFileName = "F:\USER\Medie- og Markedsafdelingen\"
        fd.Show
        filen = fd.SelectedItems(1)
    
        sql = "INSERT INTO md_tbl_dokumenter(prodid, sti, dato) VALUES(" & Str(Forms![md_mainmenu]!Prod_ny!txt_id) & ",'" & filen & "'," & Date & ")"
        
        DoCmd.SetWarnings False
        
        DoCmd.RunSQL sql
        
        DoCmd.SetWarnings True
        
        DoCmd.Close acForm, "md_frm_stivalg", acSaveNo
        
        Forms![md_mainmenu].Refresh
    So basically it opens a filedialog and inserts the select path into the table record formatted as hyperlink.

    However, if I click the link afterwards it doesn't open, but only activities the web toolbar in access.

    If I type the link manually into the table, there's no problem, so apparently there's a difference in the formatting of the hyperlink when using filedialog and when typing, or???

    Is there anything I can do to manipulate the path before adding it to the insert statement? other workarounds? Surely something simple!?!?

    Thanks in advance

    /Flix

    P.S. I just checked. A path added to the hyperlinks record in the table through filedialog is straightforward when conerted to text (e.g. F:\USER\Medie- og Markedsafdelingen) whilst one typed in manually has #F:\USER\Medie- og Markedsafdelingen#. So the # should somehow be added.... I'm not sure if it'll work just adding it to the string, but I'll post later.

    P.P.S. I seem to have solved the problem changing the INSERT clause to
    Code:
    sql = "INSERT INTO md_tbl_dokumenter(prodid, sti, dato) VALUES(" & Str(Forms![md_mainmenu]!Prod_ny!txt_id) & ",'#" & filen & "'#," & Date & ")"
    Last edited by Trinsan; 03-20-06 at 06:32.
    IT squid: networks, servers, firewalls, routers and I dabble a little with SQL-server and Access as well....

Posting Permissions

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