dbTalk Databases Forums  

Question: How can you generate a table via code?

comp.databases.ms-access comp.databases.ms-access


Discuss Question: How can you generate a table via code? in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
nospam@nospam.nospam
 
Posts: n/a

Default Question: How can you generate a table via code? - 04-15-2009 , 12:15 PM






Hello fellow Access 2003 users,

is there a way to provide a date (for example, 1/2/09) and then via
code, create the following table:

Period Start End
========================
1 1/4/09 1/10/09
2 1/11/09 1/17/09
3 1/18/09 1/24/09
etc.

this would continue on until there are 26 periods with accompanying
Start and End dates, 7 (or some number) days apart from each other.

Any help would be greatly appreciated!

Thank you.

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: Question: How can you generate a table via code? - 04-15-2009 , 12:40 PM






nospam (AT) nospam (DOT) nospam wrote:

Quote:
Hello fellow Access 2003 users,

is there a way to provide a date (for example, 1/2/09) and then via
code, create the following table:

Period Start End
========================
1 1/4/09 1/10/09
2 1/11/09 1/17/09
3 1/18/09 1/24/09
etc.

this would continue on until there are 26 periods with accompanying
Start and End dates, 7 (or some number) days apart from each other.

Any help would be greatly appreciated!

Thank you.
Check out CreateTableDef Method in help and the example code.


Reply With Quote
  #3  
Old   
Terry Kreft
 
Posts: n/a

Default Re: Question: How can you generate a table via code? - 04-16-2009 , 12:03 PM



Do you mean
1) create the table
or
2) create the data in the table
or
3) both ?



--
Terry Kreft


<nospam (AT) nospam (DOT) nospam> wrote

Quote:
Hello fellow Access 2003 users,

is there a way to provide a date (for example, 1/2/09) and then via
code, create the following table:

Period Start End
========================
1 1/4/09 1/10/09
2 1/11/09 1/17/09
3 1/18/09 1/24/09
etc.

this would continue on until there are 26 periods with accompanying
Start and End dates, 7 (or some number) days apart from each other.

Any help would be greatly appreciated!

Thank you.



Reply With Quote
  #4  
Old   
lyle fairfield
 
Posts: n/a

Default Re: Question: How can you generate a table via code? - 04-17-2009 , 08:27 AM



<rant>
It seems that the periods are contiguous. If so the "End" field is
redundant.

It seems that the periods are all of one week duration, determined by
a beginning date. If so all but the beginning date are calulated
values and redundant.

It seems, then, that the table requires only one field and one record.
Its creation can be effected with:

DBEngine(0)(0).Execute "SELECT #2009-04-01# AS [BeginningDate] INTO
[NewTable]"
(tested in Northwinds 2007.)

For my own part, I would probably store this beginning date in the
registry, a property of the database or one of its child objects, as a
tag value, or in a module, so to speak, as a constant. Making it the
default value of a text box on a form would make it both visible and
editable. But the creation of management tables which have little to
do with the data of the database, impinge on its cohesiveness and
threaten the clarity of its design, seems to be popular today; one can
only marvel.

How many millions of dollars have been lost through misinterpretation
of 1/4/09 as Jan 4, 2009 (or is that the correct interpretation)?
Microsoft is ethically lacking for carrying on with that.
</rant>

On Apr 15, 1:15*pm, nos... (AT) nospam (DOT) nospam wrote:
Quote:
Hello fellow Access 2003 users,

is there a way to provide a date (for example, 1/2/09) and then via
code, create the following table:

Period * * * * *Start * * * * * End
========================
1 * * * * * * * 1/4/09 * * * * *1/10/09
2 * * * * * * * 1/11/09 * * * * 1/17/09
3 * * * * * * * 1/18/09 * * * * 1/24/09
etc.

this would continue on until there are 26 periods with accompanying
Start and End dates, 7 (or some number) days apart from each other.

Any help would be greatly appreciated!

Thank you.


Reply With Quote
  #5  
Old   
nospam@nospam.nospam
 
Posts: n/a

Default Re: Question: How can you generate a table via code? - 04-17-2009 , 08:54 AM



If the table can be deleted and then created, great - if not, then I
guess I would just empty the data (which I can do using a delete
query). For me the tricky part is adding in the 26 records of three
fields each.

Thanks.

On Thu, 16 Apr 2009 18:03:59 +0100, "Terry Kreft" <dont (AT) spam (DOT) me.co.uk>
wrote:

Quote:
Do you mean
1) create the table
or
2) create the data in the table
or
3) both ?

Reply With Quote
Reply




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.