PC Review


Reply
Thread Tools Rate Thread

Create Table

 
 
Hydra
Guest
Posts: n/a
 
      29th Jun 2009

OK, I've got code that creates a database and creates a TableDef, but I
cannot figure out how to turn the Tabledef into a table that I can populate.
I've got code that shows how to populate an existing table from and Excel
file, but Ineed to fisrt creat the table.

Heve not found anything in help, or object browser, or external text, yet
this would seemto be a pretty basic operation.

What's worse it that I know I have done it before........
 
Reply With Quote
 
 
 
 
fredg
Guest
Posts: n/a
 
      29th Jun 2009

On Mon, 29 Jun 2009 07:22:01 -0700, Hydra wrote:

> OK, I've got code that creates a database and creates a TableDef, but I
> cannot figure out how to turn the Tabledef into a table that I can populate.
> I've got code that shows how to populate an existing table from and Excel
> file, but Ineed to fisrt creat the table.
>
> Heve not found anything in help, or object browser, or external text, yet
> this would seemto be a pretty basic operation.
>
> What's worse it that I know I have done it before........


I assume there is a reason to do this programmatically, rather than
just clicking New from the Database Table Objects window.

Any reason why you haven't used the Help files already on your
computer?

Help + Contents + Microsoft Access Help + Microsoft Data Access
Objects 3.60 + Microsoft DAO 3.60 + DAO Methods Reference + C +
CreateTableDef Method.

Or......

from the Help Contents menu navigate to:

Microsoft Jet SQL Reference + Data Definition Language + Create Table
Statement

Both methods include examples.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 
Reply With Quote
 
Hydra
Guest
Posts: n/a
 
      29th Jun 2009

I'm using the help screens and all they show is create tabledef.
Is there anyway they could make the help screens more obtuse, or create less
useful examples, or "see alsos" that point nowhere?


The reason I'm doing this programmatically is that it creates a new database
and a new table based on named ranges in an excel file. I won't know in
advance exactly which ranges exist, because the excel table is created from a
pick list in a third application.

I'm sure it is in there somewhere, and I'm a blithering idiot for not being
able to find it, but so far, no luck.

So the drilll is to have Excel Open and creat a database, create a table (or
tables) in that database, and then populate the table(s) fields with data
from the named ranges.

I know that you can create a tabledef so you can manipulate the properties
you want in your table, and then use the tabledef to create the table.

From the help screens:

"You manipulate a table definition using a TableDef object and its methods
and properties. For example, you can: " ......

Which is fine to know you can do that, but nowhere that I've found does it
say "HOW". It says you can creat a table from the tabledef by using the
OpenRecordSet method, but when you look that up it mrerely says

"Creates a new Recordset object and appends it to the Recordsets collection."

I understand that recordests are usually query driven subsets of a table or
tables. There is also a table type recordset object, and when you look that
up it tells you you can create it from a table!

That is not very helpful of the help screens because I'm trying to create
the table I need the recordset for. Neither are my textbooks helpful on this
subject.










"fredg" wrote:

> On Mon, 29 Jun 2009 07:22:01 -0700, Hydra wrote:
>
> > OK, I've got code that creates a database and creates a TableDef, but I
> > cannot figure out how to turn the Tabledef into a table that I can populate.
> > I've got code that shows how to populate an existing table from and Excel
> > file, but Ineed to fisrt creat the table.
> >
> > Heve not found anything in help, or object browser, or external text, yet
> > this would seemto be a pretty basic operation.
> >
> > What's worse it that I know I have done it before........

>
> I assume there is a reason to do this programmatically, rather than
> just clicking New from the Database Table Objects window.
>
> Any reason why you haven't used the Help files already on your
> computer?
>
> Help + Contents + Microsoft Access Help + Microsoft Data Access
> Objects 3.60 + Microsoft DAO 3.60 + DAO Methods Reference + C +
> CreateTableDef Method.
>
> Or......
>
> from the Help Contents menu navigate to:
>
> Microsoft Jet SQL Reference + Data Definition Language + Create Table
> Statement
>
> Both methods include examples.
>
> --
> Fred
> Please respond only to this newsgroup.
> I do not reply to personal e-mail
>

 
Reply With Quote
 
Hydra
Guest
Posts: n/a
 
      29th Jun 2009

Another example"

"You can use DAO objects, such as the Database, TableDef, Recordset, and
QueryDef objects, to represent objects that are used to organize and
manipulate data, such as tables and queries, in code."

OK, Swell, glad to know that.

So I have a TableDef that represents a table, which organizes my data. How
do I convert the table def into an actual table? (OK actual is meaningless
since both the Tabledef and the table are just digital constructs.) Why would
I want to use an object to represent another object? Why not use the table
object and manipulate data there?





"fredg" wrote:

> On Mon, 29 Jun 2009 07:22:01 -0700, Hydra wrote:
>
> > OK, I've got code that creates a database and creates a TableDef, but I
> > cannot figure out how to turn the Tabledef into a table that I can populate.
> > I've got code that shows how to populate an existing table from and Excel
> > file, but Ineed to fisrt creat the table.
> >
> > Heve not found anything in help, or object browser, or external text, yet
> > this would seemto be a pretty basic operation.
> >
> > What's worse it that I know I have done it before........

>
> I assume there is a reason to do this programmatically, rather than
> just clicking New from the Database Table Objects window.
>
> Any reason why you haven't used the Help files already on your
> computer?
>
> Help + Contents + Microsoft Access Help + Microsoft Data Access
> Objects 3.60 + Microsoft DAO 3.60 + DAO Methods Reference + C +
> CreateTableDef Method.
>
> Or......
>
> from the Help Contents menu navigate to:
>
> Microsoft Jet SQL Reference + Data Definition Language + Create Table
> Statement
>
> Both methods include examples.
>
> --
> Fred
> Please respond only to this newsgroup.
> I do not reply to personal e-mail
>

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      29th Jun 2009

You say you've got code that "creates a database and creates a TableDef".
What does the code look like? Creating a TableDef object is supposed to
create a table, so what you're describing doesn't really make sense.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Hydra" <(E-Mail Removed)> wrote in message
news:9B3F8289-9F3D-428F-9227-(E-Mail Removed)...
> Another example"
>
> "You can use DAO objects, such as the Database, TableDef, Recordset, and
> QueryDef objects, to represent objects that are used to organize and
> manipulate data, such as tables and queries, in code."
>
> OK, Swell, glad to know that.
>
> So I have a TableDef that represents a table, which organizes my data. How
> do I convert the table def into an actual table? (OK actual is
> meaningless
> since both the Tabledef and the table are just digital constructs.) Why
> would
> I want to use an object to represent another object? Why not use the table
> object and manipulate data there?
>
>
>
>
>
> "fredg" wrote:
>
>> On Mon, 29 Jun 2009 07:22:01 -0700, Hydra wrote:
>>
>> > OK, I've got code that creates a database and creates a TableDef, but I
>> > cannot figure out how to turn the Tabledef into a table that I can
>> > populate.
>> > I've got code that shows how to populate an existing table from and
>> > Excel
>> > file, but Ineed to fisrt creat the table.
>> >
>> > Heve not found anything in help, or object browser, or external text,
>> > yet
>> > this would seemto be a pretty basic operation.
>> >
>> > What's worse it that I know I have done it before........

>>
>> I assume there is a reason to do this programmatically, rather than
>> just clicking New from the Database Table Objects window.
>>
>> Any reason why you haven't used the Help files already on your
>> computer?
>>
>> Help + Contents + Microsoft Access Help + Microsoft Data Access
>> Objects 3.60 + Microsoft DAO 3.60 + DAO Methods Reference + C +
>> CreateTableDef Method.
>>
>> Or......
>>
>> from the Help Contents menu navigate to:
>>
>> Microsoft Jet SQL Reference + Data Definition Language + Create Table
>> Statement
>>
>> Both methods include examples.
>>
>> --
>> Fred
>> Please respond only to this newsgroup.
>> I do not reply to personal e-mail
>>



 
Reply With Quote
 
Hydra
Guest
Posts: n/a
 
      29th Jun 2009
"Creating a TableDef object is supposed to create a table, so what you're
describing doesn't really make sense."

Now I don't feel so bad, it doewn't make sense to me, either.

Code looks like


If Dir("C:\Cobra conversion\DataCheck.mdb") <> "" Then
'MsgBox "Datacheck Exists"
Kill "C:\Cobra Conversion\DataCheck.mdb"
End If
Set appAccess = CreateObject("Access.Application")
appAccess.Visible = True
With appAccess
..NewCurrentDatabase ("C:\Cobra Conversion\DataCheck.mdb")
..Visible = True
End With
Set dbs = appAccess.CurrentDb


' ----------Create a new TableDef object.
Set tdfResources = dbs.CreateTableDef("Resources")


'------------Populate the TableDef with names for each range in the
Spreadsheet
'------------Pick up the names Fromt he Workbook Names collection
For r = 1 To ActiveWorkbook.Names.Count
'MsgBox (ActiveWorkbook.Names(r).Name)
Rangename = ActiveWorkbook.Names(r).Name

'------------Then , using the TableDef Created above:
With tdfResources


'--------- Create fields and append them to the new TableDef
'--------- object. This must be done before appending the
'--------- TableDef object to the TableDefs collection of the database
.Fields.Append .CreateField(""" & Rangename & """, dbText)

'--------Finish with this loop through the TableDef
End With
'--------Pick up the next Rangename to add to the tabledef
Next r

'-----------End of looping through rangename and TableDef
'---------- Append the new TableDef object to the database.
dbs.TableDefs.Append tdfResources


----------------------------------------------------------------------------------

All of this apparently works, at least it doesn't throw any errors, but the
database does not show any tables appended, yet.



On the other hand, this did work In which case I don't need the tabledef:

Set dbs = OpenDatabase("C:/Cobra Conversion/datacheck")
dbs.Execute "CREATE TABLE Resources (ResourceID, Period, WBS, Hours,
Units )"
dbs.OpenTable ("Resources")
appAccess.RefreshDatabaseWindow


But now seems to be broken (sigh) This won't meet my needs since I need to
loop through and pick up the rangenames as above.












"Douglas J. Steele" wrote:

> You say you've got code that "creates a database and creates a TableDef".
> What does the code look like? Creating a TableDef object is supposed to
> create a table, so what you're describing doesn't really make sense.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Hydra" <(E-Mail Removed)> wrote in message
> news:9B3F8289-9F3D-428F-9227-(E-Mail Removed)...
> > Another example"
> >
> > "You can use DAO objects, such as the Database, TableDef, Recordset, and
> > QueryDef objects, to represent objects that are used to organize and
> > manipulate data, such as tables and queries, in code."
> >
> > OK, Swell, glad to know that.
> >
> > So I have a TableDef that represents a table, which organizes my data. How
> > do I convert the table def into an actual table? (OK actual is
> > meaningless
> > since both the Tabledef and the table are just digital constructs.) Why
> > would
> > I want to use an object to represent another object? Why not use the table
> > object and manipulate data there?
> >
> >
> >
> >
> >
> > "fredg" wrote:
> >
> >> On Mon, 29 Jun 2009 07:22:01 -0700, Hydra wrote:
> >>
> >> > OK, I've got code that creates a database and creates a TableDef, but I
> >> > cannot figure out how to turn the Tabledef into a table that I can
> >> > populate.
> >> > I've got code that shows how to populate an existing table from and
> >> > Excel
> >> > file, but Ineed to fisrt creat the table.
> >> >
> >> > Heve not found anything in help, or object browser, or external text,
> >> > yet
> >> > this would seemto be a pretty basic operation.
> >> >
> >> > What's worse it that I know I have done it before........
> >>
> >> I assume there is a reason to do this programmatically, rather than
> >> just clicking New from the Database Table Objects window.
> >>
> >> Any reason why you haven't used the Help files already on your
> >> computer?
> >>
> >> Help + Contents + Microsoft Access Help + Microsoft Data Access
> >> Objects 3.60 + Microsoft DAO 3.60 + DAO Methods Reference + C +
> >> CreateTableDef Method.
> >>
> >> Or......
> >>
> >> from the Help Contents menu navigate to:
> >>
> >> Microsoft Jet SQL Reference + Data Definition Language + Create Table
> >> Statement
> >>
> >> Both methods include examples.
> >>
> >> --
> >> Fred
> >> Please respond only to this newsgroup.
> >> I do not reply to personal e-mail
> >>

>
>
>


-----------------------------------------------------------------------------
Our Peering Groups change
Visit : http://spacesst.com/peerin
 
Reply With Quote
 
Hydra
Guest
Posts: n/a
 
      29th Jun 2009
I finally bumbled through something that works, but little thanks to the help
screens.



"Douglas J. Steele" wrote:

> You say you've got code that "creates a database and creates a TableDef".
> What does the code look like? Creating a TableDef object is supposed to
> create a table, so what you're describing doesn't really make sense.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Hydra" <(E-Mail Removed)> wrote in message
> news:9B3F8289-9F3D-428F-9227-(E-Mail Removed)...
> > Another example"
> >
> > "You can use DAO objects, such as the Database, TableDef, Recordset, and
> > QueryDef objects, to represent objects that are used to organize and
> > manipulate data, such as tables and queries, in code."
> >
> > OK, Swell, glad to know that.
> >
> > So I have a TableDef that represents a table, which organizes my data. How
> > do I convert the table def into an actual table? (OK actual is
> > meaningless
> > since both the Tabledef and the table are just digital constructs.) Why
> > would
> > I want to use an object to represent another object? Why not use the table
> > object and manipulate data there?
> >
> >
> >
> >
> >
> > "fredg" wrote:
> >
> >> On Mon, 29 Jun 2009 07:22:01 -0700, Hydra wrote:
> >>
> >> > OK, I've got code that creates a database and creates a TableDef, but I
> >> > cannot figure out how to turn the Tabledef into a table that I can
> >> > populate.
> >> > I've got code that shows how to populate an existing table from and
> >> > Excel
> >> > file, but Ineed to fisrt creat the table.
> >> >
> >> > Heve not found anything in help, or object browser, or external text,
> >> > yet
> >> > this would seemto be a pretty basic operation.
> >> >
> >> > What's worse it that I know I have done it before........
> >>
> >> I assume there is a reason to do this programmatically, rather than
> >> just clicking New from the Database Table Objects window.
> >>
> >> Any reason why you haven't used the Help files already on your
> >> computer?
> >>
> >> Help + Contents + Microsoft Access Help + Microsoft Data Access
> >> Objects 3.60 + Microsoft DAO 3.60 + DAO Methods Reference + C +
> >> CreateTableDef Method.
> >>
> >> Or......
> >>
> >> from the Help Contents menu navigate to:
> >>
> >> Microsoft Jet SQL Reference + Data Definition Language + Create Table
> >> Statement
> >>
> >> Both methods include examples.
> >>
> >> --
> >> Fred
> >> Please respond only to this newsgroup.
> >> I do not reply to personal e-mail
> >>

>
>
>


-----------------------------------------------------------------------------
Less Spam Better enjoyable experience
Visit : news://spacesst.com
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
To have month and year as part of the table name in CREATE TABLE or MAKE TABLE Query ichew@scs.com.sg Microsoft Access Getting Started 1 18th Apr 2006 06:38 AM
When I create a new item in my table, how can I create on in a linked table also? PaulHilgeman Microsoft Access Forms 4 17th Feb 2006 01:25 AM
Create Table Primary Key after Make Table Query And Update Table =?Utf-8?B?Uk5VU1pAT0tEUFM=?= Microsoft Access Queries 1 3rd May 2005 08:07 PM
reset button, create excel, import table, send e-mail, create back-up matthew nance Microsoft Access 0 27th Jul 2004 06:52 PM
create a source table from a special pasted value dynamic crossed table Arthemus Microsoft Excel Misc 1 29th Sep 2003 08:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:31 PM.