Adding record with code to Hyperlink datatype in Table

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.  

Who is Participating?
strong-danielConnect With a Mentor Author Commented:
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
     sNewHyperLinkName = TxtHyperLinkName.Text
     sNewHyperLinkURL = "#" & TxtHyperLinkURL.Text & "#"
     sHyperLinkRecord = sNewHyperLinkName & sNewHyperLinkURL
     DoCmd.RunSQL "Insert into [tblMainMenuLinks] (MainMenuHyperlink) values ('" & sHyperLinkRecord & "')"
    Exit Sub

    MsgBox Err.Description
    Resume Exit_CmdAddHyperLink_Click
End Sub
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.