Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Database Question

Gurus,

The following "snippet" of code works fine, without the second field
"stuff", however, with the second field "stuff" the last line errors out.
Any ideas?

NewTd.Name = "New Table Name" 'Name new table.
F1.Name = "AU_ID" 'Field 1 is titled "AU_ID"
F1.Type = dbLong 'Filed 1 contains long integers
NewTd.Fields.Append F1 'Add field 1, to the table

F2.Name = "Address" 'Field 2 is titled "address"
F2.Type = dbText 'Field 2 is contains text
F2.Size = 40 'Field 2 contains 40 bytes per entry
NewTd.Fields.Append F2 'Add field 2 to the table
MyDb.TableDefs.Append NewTd 'Add the table to the database

Thanks in advance,

David
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Database Question

Hello,

This is the Excel forum, are you creating an Access DB from Excel? Here's an
ADO example:

http://www.utteraccess.com/forums/sh...?Number=418108

Looks like I wrote and executed this in Access.

Not sure if this helps, but it creates a table with multiple fields...

Regards,
Nathan Oliver

"dfixemer" wrote:

Gurus,

The following "snippet" of code works fine, without the second field
"stuff", however, with the second field "stuff" the last line errors out.
Any ideas?

NewTd.Name = "New Table Name" 'Name new table.
F1.Name = "AU_ID" 'Field 1 is titled "AU_ID"
F1.Type = dbLong 'Filed 1 contains long integers
NewTd.Fields.Append F1 'Add field 1, to the table

F2.Name = "Address" 'Field 2 is titled "address"
F2.Type = dbText 'Field 2 is contains text
F2.Size = 40 'Field 2 contains 40 bytes per entry
NewTd.Fields.Append F2 'Add field 2 to the table
MyDb.TableDefs.Append NewTd 'Add the table to the database

Thanks in advance,

David

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Database Question

Nate,

Indeed, I'm creating a Database (Could be Access) from Excel VBA. I
also realize the ADO is newer and/or better. However, I've not yet learned
ADO but do understand some basics of DAO. Also, I would still like to
understand why the DAO code in the inital post does work with one field, but
not with two?

"Nate Oliver" wrote:

Hello,

This is the Excel forum, are you creating an Access DB from Excel? Here's an
ADO example:

http://www.utteraccess.com/forums/sh...?Number=418108

Looks like I wrote and executed this in Access.

Not sure if this helps, but it creates a table with multiple fields...

Regards,
Nathan Oliver

"dfixemer" wrote:

Gurus,

The following "snippet" of code works fine, without the second field
"stuff", however, with the second field "stuff" the last line errors out.
Any ideas?

NewTd.Name = "New Table Name" 'Name new table.
F1.Name = "AU_ID" 'Field 1 is titled "AU_ID"
F1.Type = dbLong 'Filed 1 contains long integers
NewTd.Fields.Append F1 'Add field 1, to the table

F2.Name = "Address" 'Field 2 is titled "address"
F2.Type = dbText 'Field 2 is contains text
F2.Size = 40 'Field 2 contains 40 bytes per entry
NewTd.Fields.Append F2 'Add field 2 to the table
MyDb.TableDefs.Append NewTd 'Add the table to the database

Thanks in advance,

David

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Database Question



"dfixemer" wrote:

Nate,

Indeed, I'm creating a Database (Could be Access) from Excel VBA. I
also realize the ADO is newer and/or better. However, I've not yet learned
ADO but do understand some basics of DAO. Also, I would still like to
understand why the DAO code in the inital post does work with one field, but
not with two?

"Nate Oliver" wrote:

Hello,

This is the Excel forum, are you creating an Access DB from Excel? Here's an
ADO example:

http://www.utteraccess.com/forums/sh...?Number=418108

Looks like I wrote and executed this in Access.

Not sure if this helps, but it creates a table with multiple fields...

Regards,
Nathan Oliver

"dfixemer" wrote:

Gurus,

The following "snippet" of code works fine, without the second field
"stuff", however, with the second field "stuff" the last line errors out.
Any ideas?

NewTd.Name = "New Table Name" 'Name new table.
F1.Name = "AU_ID" 'Field 1 is titled "AU_ID"
F1.Type = dbLong 'Filed 1 contains long integers
NewTd.Fields.Append F1 'Add field 1, to the table

F2.Name = "Address" 'Field 2 is titled "address"
F2.Type = dbText 'Field 2 is contains text
F2.Size = 40 'Field 2 contains 40 bytes per entry
NewTd.Fields.Append F2 'Add field 2 to the table
MyDb.TableDefs.Append NewTd 'Add the table to the database

Thanks in advance,

David

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Database Question

Hello again David,

Not sure, but like my ADO example (I would use ADO...), I would use a
'Create Table' SQL statement, which you can use with DAO as well. Please see
the following:

http://msdn.microsoft.com/library/en.../D2/S5A320.asp

Regards,
NPO

"dfixemer" wrote:

Nate,

Indeed, I'm creating a Database (Could be Access) from Excel VBA. I
also realize the ADO is newer and/or better. However, I've not yet learned
ADO but do understand some basics of DAO. Also, I would still like to
understand why the DAO code in the inital post does work with one field, but
not with two?

"Nate Oliver" wrote:

Hello,

This is the Excel forum, are you creating an Access DB from Excel? Here's an
ADO example:

http://www.utteraccess.com/forums/sh...?Number=418108

Looks like I wrote and executed this in Access.

Not sure if this helps, but it creates a table with multiple fields...

Regards,
Nathan Oliver

"dfixemer" wrote:

Gurus,

The following "snippet" of code works fine, without the second field
"stuff", however, with the second field "stuff" the last line errors out.
Any ideas?

NewTd.Name = "New Table Name" 'Name new table.
F1.Name = "AU_ID" 'Field 1 is titled "AU_ID"
F1.Type = dbLong 'Filed 1 contains long integers
NewTd.Fields.Append F1 'Add field 1, to the table

F2.Name = "Address" 'Field 2 is titled "address"
F2.Type = dbText 'Field 2 is contains text
F2.Size = 40 'Field 2 contains 40 bytes per entry
NewTd.Fields.Append F2 'Add field 2 to the table
MyDb.TableDefs.Append NewTd 'Add the table to the database

Thanks in advance,

David

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Question? dbrumit Excel Discussion (Misc queries) 5 January 18th 07 09:01 PM
Member database question! Lars Grøtteland Excel Worksheet Functions 0 September 6th 06 01:57 PM
Template & Database Question SteveT Excel Worksheet Functions 2 June 10th 06 11:07 PM
Database question clarification Jim[_22_] Excel Programming 3 April 21st 04 12:37 AM
Database question Jim[_22_] Excel Programming 5 April 19th 04 10:16 PM


All times are GMT +1. The time now is 06:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"