Solved

Adding record with code to Hyperlink datatype in Table

Posted on 2008-06-25
1
1,077 Views
Last Modified: 2013-11-29
I have a list box that is plugged into a table with that only has one field, it is a hyperlink field.  

I want to give the user the option of adding a new hyperlink to the listbox.  Which means, adding a new record to the table the listbox is plugged into.

Once the user clicks the "Add Hyperlink" button, I have it pop open a new form with 2 textbox's and a button.

The first textbox is the hyperlink name or text that is displayed, the second textbox is for the URL.  

Can someone give me some sample VBA code on how to add the strings for the 2 textbox's to a hyperlink field?  

Not sure how to do it...  Not real good with Access yet.   I am using Access 2003.   I noticed in order to get the URL correctly out of the hyperlink field, you have to use HyperlinkPart method and it parses the database record that is hyperlink type.  

Thanks...
0
Comment
Question by:strong-daniel
1 Comment
 

Accepted Solution

by:
strong-daniel earned 0 total points
Comment Utility
I figured this out and it was simple.  Here is the code...

Private Sub cmdAddHyperlink_Click()
On Error GoTo Err_CmdAddHyperLink_Click

   
   ' DoCmd.GoToRecord , , acNewRec
     
     Dim sNewHyperLink As String
     Dim sNewHyperLinkName As String
     Dim sNewHyperLinkURL As String
     Dim sHyperLinkRecord As String
     
     TxtHyperLinkName.SetFocus
     sNewHyperLinkName = TxtHyperLinkName.Text
     
     TxtHyperLinkURL.SetFocus
     sNewHyperLinkURL = "#" & TxtHyperLinkURL.Text & "#"
     
     sHyperLinkRecord = sNewHyperLinkName & sNewHyperLinkURL
     
     DoCmd.RunSQL "Insert into [tblMainMenuLinks] (MainMenuHyperlink) values ('" & sHyperLinkRecord & "')"
     
   
     
Exit_CmdAddHyperLink_Click:
    Exit Sub

Err_CmdAddHyperLink_Click:
    MsgBox Err.Description
    Resume Exit_CmdAddHyperLink_Click
   
End Sub
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now