Results 1 to 12 of 12
  1. #1
    Join Date
    May 2006
    Posts
    386

    Unanswered: Is it possible to create a command button on a form to Insert hyperlink?

    Dear All,
    I have a form which is based on a table, one of the fields in the table is called "Upload File" and the data type of this field is hyperlink.
    I want a command button next to this field on the on the form to be called "Inser File". And as the user clicks on this command button, it should open the same window as if you were to Click on the insert Menu at the top of the page and then clicking on the Hyperlink.

    The reason I dont want to use the standard Insert/hyperlink from the top menu is that I dont want users to be able to view the menus and toolbars when the database starts up. that is why I want to create a command button.

    I would really appreciate any help.
    emi
    Emi-UK
    Love begets Love, Help Begets Help

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Use the DoCmd.RunCommand ......... function that is available in MS-Access. Anything that can be done through menus can be also done with this function. Simply view the list of commands available when you hit the spacebar after you enter the RunCommand statement and then select the Hyperlink function you would like to carry out.

    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  3. #3
    Join Date
    May 2006
    Posts
    386
    Hi Cyberlynx,
    Thanks for your help. But when I created a command button on the form and added this code on the behind the command button
    Private Sub CmdUploadFile_Click()
    DoCmd.RunCommand acCmdInsertHyperlink
    End Sub
    and after I put my cursor on the field whose data type is hyperlink and then click on the command button, I get a runtime error message saying
    Runtime Error 2046
    The command or action "inserthyperlink" isnt availbale now
    Am I missing someting in the code?
    Emi-UK
    Love begets Love, Help Begets Help

  4. #4
    Join Date
    May 2006
    Posts
    386
    Could anyone please help me with this? I have not had an response yet? Thank you for your help.
    Emi-UK
    Love begets Love, Help Begets Help

  5. #5
    Join Date
    May 2006
    Posts
    386
    Could you someone please help? I know the reason why I get the error. It is because I have unticked the Display Windows and Full Menus From the Tool/Startup option. But I want the command button to open the "Insert" then "hyperLink" option while the Display Windows Objects and Full Menu is off. ANY HELP WOULD BE MUCH APPRECIATED. Thanks , emi
    Emi-UK
    Love begets Love, Help Begets Help

  6. #6
    Join Date
    Dec 2006
    Posts
    53
    It's an error similar to the one here http://support.microsoft.com/kb/244695/, so I think the solution might be similar. I would suggest, just as troubleshooting, to try using the button when the DB window is not hidden. If it then works, then you have to use the second resolution that MS suggests.

  7. #7
    Join Date
    May 2006
    Posts
    386
    I looked at this code and system but it wont work on my db. It is because I want to insert a file and the code you are suggesting is referring to opening a form or report. I have found a similar function on the net and strangely it works on the example BUT when i copied and pasted the whole code in my db, it does not open the file and it only brings open the "web" toolbar from the "View" menu. please look at the attached example and kindly advise what I am missing and what could the reason it doesnt work on my db. I mean it doesnt open the file on my db after you click on the hyperlink. thanks in advance
    Attached Files Attached Files
    Emi-UK
    Love begets Love, Help Begets Help

  8. #8
    Join Date
    Dec 2006
    Posts
    53
    It's fixed. I was pretty sure that in order to link to a file on the local computer, you need file:\\\ in front of the path. When that didn't work, I noticed that in the sample I inserted as record 2 (directly via the table, not the form), the path was preceded and proceeded by the # character. The attached database seems to work!
    Attached Files Attached Files

  9. #9
    Join Date
    May 2006
    Posts
    386
    yes, it was working before as well BUT my db didnt work and doesnt open the file. Also, PLEASE NOTE that I would only be using the form to insert a hyperlink NOT the table. Will this still work? or do I have to manually insert a \ before the other two existing\\ ?
    Emi-UK
    Love begets Love, Help Begets Help

  10. #10
    Join Date
    Dec 2006
    Posts
    53
    When I run the database I sent back to you, it works just as you asked that it would. I clicked on the first Add button to add the path to a file on my computer. Then when I click the field, the file opens. It's working beautifully for me!

    Now, I assume that the "hyperlink" you will be inserting will always be a local file rather than an http?

  11. #11
    Join Date
    May 2006
    Posts
    386
    HI Defwelch,
    Thank you so much. Mistry solved. However, I actually was trying to use acCmdHyperlink but as I found this example on the net, then I thought why not to change the data type of the strImathPath filed into Hyperlink and it will do the same task. So I did it and with your final help it serves my purpose now.

    thanks and have a great time
    Emi-UK
    Love begets Love, Help Begets Help

  12. #12
    Join Date
    Aug 2012
    Location
    Heredia, Costa Rica
    Posts
    4

    Thumbs up

    Thanks I was stuck as well. I am using Access 2003 and didn't want to use the OLE.

    Also, if someone else is interested here is another useful post: http://www.access-programmers.co.uk/...d.php?t=151566

    Quote Originally Posted by dfwelch View Post
    It's fixed. I was pretty sure that in order to link to a file on the local computer, you need file:\\\ in front of the path. When that didn't work, I noticed that in the sample I inserted as record 2 (directly via the table, not the form), the path was preceded and proceeded by the # character. The attached database seems to work!
    Last edited by vicsar; 10-19-12 at 23:34.

Posting Permissions

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