(Q) I'm unable to create a Hyperlink Field in a table from code.
What are the steps that I need to take or is this possible?
(A) To create a Hyperlink field, you need to set the Attributes to
dbHyperlinkField.
Try this function as an example.
Function fTableWithHyperlink(stTablename As String) As Boolean
On Local Error GoTo fTableWithHyperlink_Err
Dim Msg As String
Dim db As Database
Dim tdf As TableDef
Dim fld As Field
Set db = CurrentDb
Set tdf = db.CreateTableDef(stTablename)
Set fld = tdf.CreateField("HyperlinkTest", dbMemo)
fld.Attributes = dbHyperlinkField
tdf.Fields.Append fld
tdf.Fields.Refresh
db.TableDefs.Append tdf
db.TableDefs.Refresh
Set fld = Nothing
Set tdf = Nothing
Set db = Nothing
fTableWithHyperlink = True
fTableWithHyperlink_End:
Exit Function
fTableWithHyperlink_Err:
fTableWithHyperlink = False
Msg = "Error Information..." & vbCrLf & vbCrLf
Msg = Msg & "Function: fTableWithHyperlink" & vbCrLf
Msg = Msg & "Description: " & Err.Description & vbCrLf
Msg = Msg & "Error #: " & Format$(Err.Number) & vbCrLf
MsgBox Msg, vbInformation, "fTableWithHyperlink"
Resume fTableWithHyperlink_End
End Function
|