How to create a Hyperlink-column in an Access database table with VB6?
Hi,
I'm searching for some time now for code to create a hyperlink column in a table in an Access database, with Visual Basic 6 ( a column containing hyperlinks)
Creating other type of columns is no problem, e.g. Text columns, Date columns:
VB6 code:
Code:
Set MyDatabase = New ADODB.Connection
MyDatabase.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & TableName & ";" & "Persist Security Info=False"
MyDatabase.Open
MyDatabase.Execute "CREATE TABLE " & NewTableName & "(" & _
"ID HYPERLINK ," & _ (HYPERLINK gives a runtime error)
"ExpCode VARCHAR(50) ," & _ (creates a text column - works fine)
"Concerning MEMO ," & _ (creates a memo column - works fine)
"Date_ DATETIME )" (creates a date column - works fine)
VARCHAR(50), MEMO, DATETIME all create the type of column that I want, only HYPERLINK, or LINK, or HYPERLINKNAME... etc... (tried them all) do not create a hyperlink column but give errors.
I searched for hours but I just can't find it.
Is there any way to create a Hyperlink column with VB6-code?
Help will be greatly appreciated!:thumb:
Re: How to create a Hyperlink-column in an Access database table with VB6?
I'm afraid not, no.
This site says you can't do it:
http://allenbrowne.com/func-DDL.html
Re: How to create a Hyperlink-column in an Access database table with VB6?
Store the link as straight text, and make it a hyperlink when you bring it out of the database and display it.
Re: How to create a Hyperlink-column in an Access database table with VB6?
Thank you, PilgrimPete, I was already afraid it was not possible.
And thank you Hack, but you seem to have some kind of solution:
"Store the link as straight text, and make it a hyperlink when you bring it out of the database and display it."
What exactly do you mean with "bring it out of the database and display it" ?
So,the link as text could be something like:
"SomeLink#C:\Data\SomeDocument.doc"
How to display SomeLink as the link?
Re: How to create a Hyperlink-column in an Access database table with VB6?
By the way, is it possible in VB.Net?
Re: How to create a Hyperlink-column in an Access database table with VB6?
In C# there is a thing called a LinkLabel, I assume that VB has one too.
That will do what Hack suggests.
Re: How to create a Hyperlink-column in an Access database table with VB6?
With DAO, it looks like:
Code:
Set fldID = tdf.CreateField("ID", dbMemo)
fldID.Attributes = dbHyperlinkField + dbVariableField
tdf.Fields.Append fldID
Hyperlink is an attribute add to a Memo field, so Hyperlink field is actual a Memo field with a special attribute.
There is no Field Data Type called HYPERLINK:
Code:
Table Fields : Hyperlink
Query Parameters : Memo
Visual Basic : String
ADO Data Type property constants : adLongVarWChar
Microsoft Access database engine
SQL and synonyms : LONGTEXT (Synonyms: LONGCHAR, MEMO, NOTE)