Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Hyperlink Field In Code 1

Status
Not open for further replies.

Kocheace

Vendor
Oct 31, 2002
97
US
I'm creating a table in code and the contents of one of the fields I want to be Hyperlinks. But the hyperlink data type isn't an option for the field type? It's only dbtext,dbinteger etc.

Does anyone know of a way to create a hyperlink field in code? IT Professional
 
Hi I was feeling a bit lazy earlier, here's an example of how to use dbHyperlinkField:

Sub CreateMyTable()
Dim dbs As Database, tdf As TableDef, fld As Field
Set dbs = CurrentDb
Set tdf = dbs.CreateTableDef("MyHyperlinkTable")
With tdf
.Fields.Append .CreateField("FirstName", dbText) 'create your non-HyperlinkField's first
.Fields.Append .CreateField("LastName", dbText)
.Fields.Append .CreateField("Phone", dbText)
End With
Set fld = tdf.CreateField("MyHyperlinkField", dbMemo) 'create your HyperLink field, must be set as Memo
fld.Attributes = dbHyperlinkField 'then set attributes to dbHyperlinkField
tdf.Fields.Append fld
dbs.TableDefs.Append tdf
dbs.Close
End Sub
 
Thanks a lot bill. I just knew there had to be a way to set the field type to hyperlink. I set the field to memo and it works perfectly. I owe you big time!

IT Professional
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top