473,395 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Create table with Hyperlink field

Hello All,

Ok I've read it is not necessarily a good ideal to create a hyperlink
field in a database, but I've tried. I've also read that a hyperlink
field is a memo field with attributes of dbHyperlinkField +
dbVariableField. So I tried using the code below, and received the error
below. Any ideals? Thanks!

,----- [ Error message on 'db.TableDefs.Append tdf' ]
| Run-time error '3010':
|
| Table 'Supplier' already exists.
`-----

=====================>Begin Code>===================================>
Sub CreateSuppliersWithHyperLink()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field

Set db = CurrentDb()
Set tdf = db.CreateTableDef("Suppliers")

With tdf
.Fields.Append .CreateField("SupplierID", dbLong)
.Fields.Append .CreateField("CompanyName", dbText, 40)
.Fields.Append .CreateField("ContactName", dbText, 30)
.Fields.Append .CreateField("ContactTitle", dbText, 30)
.Fields.Append .CreateField("Address", dbText, 60)
.Fields.Append .CreateField("City", dbText, 15)
.Fields.Append .CreateField("Region", dbText, 15)
.Fields.Append .CreateField("PostalCode", dbText, 10)
.Fields.Append .CreateField("Country", dbText, 15)
.Fields.Append .CreateField("Phone", dbText, 24)
.Fields.Append .CreateField("Fax", dbText, 24)
.Fields.Append .CreateField("Homepage", dbMemo)

For Each fld In .Fields
If fld.name = "Homepage" Then
Debug.Print "ok your in the loop"
fld.Attributes = dbHyperlinkField + dbVariableField
End If
Next fld

End With

db.TableDefs.Append tdf

Set fld = Nothing
Set tdf = Nothing
Set db = Nothing
RefreshDatabaseWindow

End Sub
=====================<End Code<===================================<

--
Regards,

Greg Strong
Mar 20 '06 #1
4 8589
Br
Greg Strong wrote:
Hello All,

Ok I've read it is not necessarily a good ideal to create a hyperlink
field in a database, but I've tried. I've also read that a hyperlink
field is a memo field with attributes of dbHyperlinkField +
dbVariableField. So I tried using the code below, and received the
error below. Any ideals? Thanks!

,----- [ Error message on 'db.TableDefs.Append tdf' ]
Run-time error '3010':

Table 'Supplier' already exists.


So, the table exists already. Delete it and try again???

<>

--
regards,

Br@dley
Mar 20 '06 #2
Greg, I suspect this is an issue of timing.

Try setting the attributes before appending the field to the table's Fields
collection:

Set fld = .CreateField("HomePage", dbMemo)
fld.Attributes = dbHyperlinkField + dbVariableField
.Append fld
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Greg Strong" <NoJunk@NoJunk4U˛.com> wrote in message
news:tf********************************@4ax.com...
Hello All,

Ok I've read it is not necessarily a good ideal to create a hyperlink
field in a database, but I've tried. I've also read that a hyperlink
field is a memo field with attributes of dbHyperlinkField +
dbVariableField. So I tried using the code below, and received the error
below. Any ideals? Thanks!

,----- [ Error message on 'db.TableDefs.Append tdf' ]
| Run-time error '3010':
|
| Table 'Supplier' already exists.
`-----

=====================>Begin Code>===================================>
Sub CreateSuppliersWithHyperLink()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field

Set db = CurrentDb()
Set tdf = db.CreateTableDef("Suppliers")

With tdf
.Fields.Append .CreateField("SupplierID", dbLong)
.Fields.Append .CreateField("CompanyName", dbText, 40)
.Fields.Append .CreateField("ContactName", dbText, 30)
.Fields.Append .CreateField("ContactTitle", dbText, 30)
.Fields.Append .CreateField("Address", dbText, 60)
.Fields.Append .CreateField("City", dbText, 15)
.Fields.Append .CreateField("Region", dbText, 15)
.Fields.Append .CreateField("PostalCode", dbText, 10)
.Fields.Append .CreateField("Country", dbText, 15)
.Fields.Append .CreateField("Phone", dbText, 24)
.Fields.Append .CreateField("Fax", dbText, 24)
.Fields.Append .CreateField("Homepage", dbMemo)

For Each fld In .Fields
If fld.name = "Homepage" Then
Debug.Print "ok your in the loop"
fld.Attributes = dbHyperlinkField + dbVariableField
End If
Next fld

End With

db.TableDefs.Append tdf

Set fld = Nothing
Set tdf = Nothing
Set db = Nothing
RefreshDatabaseWindow

End Sub
=====================<End Code<===================================<

--
Regards,

Greg Strong

Mar 20 '06 #3
On Mon, 20 Mar 2006 16:17:28 +1100, "Br@dley" <do***********@google.com>
wrote:
So, the table exists already. Delete it and try again???


It is deleted. I should have originally stated this explicitly. This is
why the error message is so strange. In the procedure that I run, I
delete all of the relationships and tables, then start from scratch.

Thanks!
--
Regards,

Greg Strong
Mar 20 '06 #4
On Mon, 20 Mar 2006 13:59:12 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
Try setting the attributes before appending the field to the table's Fields
collection:

Set fld = .CreateField("HomePage", dbMemo)
fld.Attributes = dbHyperlinkField + dbVariableField
.Append fld


I used your suggestion. It worked. The short answer is I think that I
may have had some conflicts with references set in my working copy of
NorthWind which is where I was doing some testing. After dumping module,
and re-importing module into fresh NW, then the code worked. The main
reason was I did this was because I couldn't find a way to create a
hyperlink field type using DDL running from code. FWIW the code is
below.

Thanks!

--
Regards,

Greg Strong

=====================>Begin Code>===================================>
Sub CreateSuppliersWithHyperLink()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fldSupplierID As DAO.Field
Dim fldCompanyName As DAO.Field
Dim fldContactName As DAO.Field
Dim fldContactTitle As DAO.Field
Dim fldAddress As DAO.Field
Dim fldCity As DAO.Field
Dim fldRegion As DAO.Field
Dim fldPostalCode As DAO.Field
Dim fldCountry As DAO.Field
Dim fldPhone As DAO.Field
Dim fldFax As DAO.Field
Dim fldHomepage As DAO.Field

Set db = CurrentDb()

On Error Resume Next
' Delete the table if it already exists.
db.TableDefs.Delete "Suppliers"
On Error GoTo 0

Set tdf = db.CreateTableDef()
tdf.name = "Suppliers"

Set fldSupplierID = tdf.CreateField("SupplierID", dbLong)
Set fldCompanyName = tdf.CreateField("CompanyName", dbText, 40)
Set fldContactName = tdf.CreateField("ContactName", dbText, 30)
Set fldContactTitle = tdf.CreateField("ContactTitle", dbText, 30)
Set fldAddress = tdf.CreateField("Address", dbText, 60)
Set fldCity = tdf.CreateField("City", dbText, 15)
Set fldRegion = tdf.CreateField("Region", dbText, 15)
Set fldPostalCode = tdf.CreateField("PostalCode", dbText, 10)
Set fldCountry = tdf.CreateField("Country", dbText, 15)
Set fldPhone = tdf.CreateField("Phone", dbText, 24)
Set fldFax = tdf.CreateField("Fax", dbText, 24)
Set fldHomepage = tdf.CreateField("Homepage", dbMemo)
fldHomepage.Attributes = dbHyperlinkField + dbVariableField

With tdf.Fields
.Append fldSupplierID
.Append fldCompanyName
.Append fldContactName
.Append fldContactTitle
.Append fldAddress
.Append fldCity
.Append fldRegion
.Append fldPostalCode
.Append fldCountry
.Append fldPhone
.Append fldFax
.Append fldHomepage
End With

With db.TableDefs
.Append tdf
.Refresh
End With

Set fldSupplierID = Nothing
Set fldCompanyName = Nothing
Set fldContactName = Nothing
Set fldContactTitle = Nothing
Set fldContactTitle = Nothing
Set fldAddress = Nothing
Set fldCity = Nothing
Set fldRegion = Nothing
Set fldPostalCode = Nothing
Set fldCountry = Nothing
Set fldPhone = Nothing
Set fldFax = Nothing
Set fldHomepage = Nothing
Set tdf = Nothing
Set db = Nothing
Application.RefreshDatabaseWindow

End Sub
=====================<End Code<=====================================<

Mar 21 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: deko | last post by:
Is there a special syntax for hyperlinks in queries? I have a table of hyperlinked documents displayed in a subform datasheet. Clicking the hyperlink opens the document from the hard drive. I...
5
by: Gamesetal | last post by:
Have '97 and am trying to create a query on the underlying Hyperlink field - ie if xxx then else ... Can't find a way to do this and would very much appreciate some kind help - thanks - John
4
by: Miguel Dias Moura | last post by:
Hello, I created a datalist in an ASP.Net / VB page. I display the image and price of a few products. When a user clicks an image I want to load the page "detail.aspx?number=id" and send the...
3
by: sloesch | last post by:
I am working with VS.net 2003, framework 1.1, developing with VB.net, and ASP.net, and I would like to know how you can create a dynamic hyperlink on the fly to a document stored in a SQL database?...
4
by: BLob | last post by:
Hi, I need to create an RTF document with PHP. Actually, I am using an already created RTF document which with strings like %var% that I replace with $var before sending the document. I need to...
3
by: The Woo | last post by:
Can one programatically create a file folder which has the same name as a key field, using a command button? Or, Can there be a a command button which opens up a directory tree to a specified...
1
by: daniellee2006 | last post by:
I am creating a basic website to store people profiles and within this website i have a page that creates a table dependent on the number of records in mysql written in PHP within these tables...
22
by: mforema | last post by:
Hey Everybody, I have an URGENT REQUEST (I need a reply within 24 hours, or I lose my job) I need help writing vba code for a command button. I want this button to locate a hyperlink in a table (the...
13
ADezii
by: ADezii | last post by:
Recently, there have been several questions and much confusion concerning the Topic of Hyperlinks. Specifically, Users wanted to know how to retrieve a File Name from a FileDialog Box, copy the Name...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.