Solved Using a form to update a hyperlink in a table (1 Viewer)

theferd

Registered User.
Local time
Today, 05:43
Joined
Dec 23, 2019
Messages
42
Hi All, I am having issues with making use of hyperlink object in an Update SQL.

I have a form where a user pastes the URL to a drawing in a text box. I have a table, Drawings, with fields "ID" and "Links".
The link will be transferred to the field in the table corresponding to the ID they selected in a combo box. I can have the raw url appear in the field but I want a Display text to show "Link" over the URL.

If IsNull(Me.cmboID) = True Then
Else
Dim updatesql As String
updatesql = "Update Drawings Set Links = {Hyperlink stuff??}" & me.txtlink & " Where [ID] = " & Me.cmboID & ""
DoCmd.RunSQL updatesql
End If

I'm not quite sure how to aggregate texttodisplay and address in a single SQL statement.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 02:43
Joined
Aug 30, 2003
Messages
36,124
Generally speaking:

updatesql = "Update Drawings Set Links = 'some fixed text here' & me.txtlink & " Where [ID] = " & Me.cmboID & ""
 

theferd

Registered User.
Local time
Today, 05:43
Joined
Dec 23, 2019
Messages
42
This doesn't work. It just generates Link'Url' and causes a missing parameter error.

updatesql = "Update Drawing Set Links= link" & Me.txtlink & " Where [ID] = " & Me.cmboID & "" - for reference
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 02:43
Joined
Aug 30, 2003
Messages
36,124
What is link supposed to be? If that's a variable, it needs to be concatenated into the string like the form reference.
 

theferd

Registered User.
Local time
Today, 05:43
Joined
Dec 23, 2019
Messages
42
The link will be some url pasted into a textbox (Me.txtlink) by a user. After a button click it will be transferred to the table. Something like https://www.google.com/. But on the table and through searches, it will only appears "Link" in the hyperlink field.
 

sonic8

AWF VIP
Local time
Today, 11:43
Joined
Oct 27, 2015
Messages
998
Maybe you should reconsider using the Hyperlink data type. - It creates all sorts of problems.
I dislike the Hyperlink data type so much, I even wrote a Text about it. -> Issues with Hyperlinks
Even if you still want to use it, that text should contain information to solve your problem.
 

theferd

Registered User.
Local time
Today, 05:43
Joined
Dec 23, 2019
Messages
42
I appreciate the concern and might go with this method in a future project but for now the project has gone far enough that it would be tedious work to replace relationships related to the links. The documentation this provided though has helped solve my issue.
The solution for those curious:

If IsNull(Me.cmboID) = True Then
Else
Dim updatesql As String
updatesql = "Update Drawings Set Links = 'Link#" & me.txtlink & "#' Where [ID] = " & Me.cmboID & ""
DoCmd.RunSQL updatesql
End If
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 02:43
Joined
Aug 30, 2003
Messages
36,124
Glad you got it sorted. Like sonic, I never use the hyperlink data type.
 

Users who are viewing this thread

Top Bottom