Creating an access table with ADO

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anyone know how to turn this into a Loop? I don't want to hardcode my
table field names. Thank you in advance!

Field1 = ActiveWorkbook.Worksheets("mysheet1").Range("C1").Value
Field2 = ActiveWorkbook.Worksheets("mysheet2").Range("D1").Value
Field3 = ActiveWorkbook.Worksheets("mysheet3").Range("E1").Value

cnn.Execute _
"CREATE TABLE tblOutput(" & _
Field1 & " VARCHAR(1) NOT NULL," & _
Field2 & " VARCHAR(20) NOT NULL," & _
Field3 & " VARCHAR(20) NOT NULL)"
 
What are you trying to do? Are you trying to populate at table that you
create on the fly or are you trying to create multiple tables on the fly? It
is hard to tell from what you have here.
 
I'm trying to create a table on the fly based on the field names that are
typed into the excel spreadsheet. It works the way I indicated in my first
message, however I want to turn it into a loop so it will create a table
based on how many fields I decide to type into the spreadsheet. The field
names start at cell C1 in "mySheet1" (sorry in my previous msg it shows 3
different worksheets but it should only be mySheet1). I hope this makes
sense. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top