Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Adding record with code to Hyperlink datatype in Table

Posted on 2008-06-25
1
Medium Priority
?
1,087 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
strong-daniel earned 0 total points
ID: 21870472
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

715 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