Results 1 to 7 of 7

Thread: How to create a Hyperlink-column in an Access database table with VB6?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2007
    Location
    Arnhem, the Netherlands
    Posts
    5

    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!

  2. #2
    Frenzied Member PilgrimPete's Avatar
    Join Date
    Feb 2002
    Posts
    1,313

    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

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2007
    Location
    Arnhem, the Netherlands
    Posts
    5

    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?

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2007
    Location
    Arnhem, the Netherlands
    Posts
    5

    Re: How to create a Hyperlink-column in an Access database table with VB6?

    By the way, is it possible in VB.Net?

  6. #6
    Frenzied Member PilgrimPete's Avatar
    Join Date
    Feb 2002
    Posts
    1,313

    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.

  7. #7
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    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)
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width