By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,723 Members | 1,703 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,723 IT Pros & Developers. It's quick & easy.

Changing the data type of a field to hyperlink

P: n/a
I have an Excel spreadsheet containing a column of hyperlinks that I
need to import into Access. I have no trouble importing (in my case
actually linking) the spreadhsheet to the Access table, however the
column of hyperlinks lose their URL's in transit and no longer are
active links. To try and fix the problem I am using this bit of code
in my Excel spreadsheet to copy the URL of each hyperlink into a new
column that can then be imported into Access:

'Code Starts
Public Function GetURL(R As Range) As Variant
If R.Hyperlinks.Count > 0 Then
GetURL = R.Hyperlinks(1).Address
GetURL = Null
End If
Set C = Nothing
End Function
'Code Ends

The only thing I need help with is figuring out how to change the data
type of this URL field to "hyperlink" once it has been imported. I
know how to do this manually but for the purpose of my database I will
need to do this by VB coding. Any help would be much appreciated!

Jun 6 '06 #1
Share this Question
Share on Google+
3 Replies

P: n/a
In your Access table, is the field itself defined as a Hyperlink? I would
think that would take care of it.
Jun 6 '06 #2

P: n/a

Rick Wannall wrote:
In your Access table, is the field itself defined as a Hyperlink? I would
think that would take care of it.

That's the thing....when access imports the table it defines the field
as text but I need to change it to hyperlink via code.

Jun 6 '06 #3

P: n/a
From Access Help:

(Field) Type Property
Sets or returns a value that indicates the operational type or data type of
an object.
Settings and Return Values
The setting or return value is a constant that indicates an operational or
data type. For a Field <daobjfield.htm> or Property <daobjproperty.htm>
object, this property is read/write until the object is appended to a
collection or to another object, after which it's read-only. For a QueryDef
<daobjquerydef.htm>, Recordset <daobjrecordset.htm>, or Workspace
<daobjworkspace.htm> object, the property setting is read-only.

Can't change the type of a field after it's in the table.

You can create a new field, any type you like (in this case hyperlink), add
that to your table, and then copy the values from the text field to the
hyper link column. Code for the field creation, one action query to copy
the values.

Since, however, you can specify code in a form that will follow a hyperlink
even from a text field you may not actually need to do this, unless you just
have to have the ability to click on the address in a datasheet and follow
the link.
Jun 6 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.