Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating a form that creates a table

Status
Not open for further replies.

Eric6

Programmer
Jun 11, 2002
54
CA
hello
just a quick question

i was wonderring if i could use a form to create a table...
all i would really have to do is have the form
create a copy of a "dumy" table (an empty table with all the proper columns)
then, all it would have to do is name (or rename) the copy of the dumy to match a number given by the user (for example, if the user give the number 9, the form should create a table called RO009...)

i'm sure this is possible
but i couldn't find the function necessairy in the
help files....

thank you in advance
Eric
 
Be forwarned, databases can get out of hand quickly if lots of people make lots of tables. If you have any other options, I would consider them carefully. That said, here's the easiest method I can think of...

You can make a master version of this dummy table, then use the CopyObject method with a command button on your form.

Here's is the syntax for CopyObject
DoCmd.CopyObject [destination database - leave this blank if it's the same database] [,name of copy] [,type] [,name of original]

If you want the user to be able to assign a name to the new table, create a text box in the form (txtNewTableName), and reference it in the code like this:
strNewTableName = Me.txtNewTableName.Value (then use the expression strNewTableName in the name of copy part of the expression)

So your code would go something like this...

Dim strNewTableName As String
strNewTableName = Me.txtNewTableName.Value
DoCmd.CopyObject ,strNameTableName, acTable, "master table"

Hopefully this will get you started

Good luck
C.


 
I have seen code to do it, but WHY? Your application will then have a table that the rest of the application knows nothing about. You won't be able to save records to it, etc.

Better to have a table that allows the user to create a new "level" of "RO009" and then add records to a table with the structure (from your "dummy" table) that has an extra field that has your level key "RO009" as the key.

Maybe I don't understand.. Terry
**************************
* General Disclaimor - Please read *
**************************
Please make sure your post is in the CORRECT forum, has a descriptive title, gives as much detail to the problem as possible, and has examples of expected results. This will enable me and others to help you faster...
 
thank you for the help

but i think i'm not gonna use it,
i first thought of using a single tables for each RO but
that would result in at least 20 tables,
so i'm pretty sure things would slow down...
(not sure thought, its my first time using access)

the program would of still been able to "see" the new tables
because i have a "master" list of RO's that
i would of used to open the appropriate tables,
and since all the tables look alike, i can use the same
form to open and add to the table....

anyways, i think i'm just gonna use a single (huge) table
for every single RO entry...
it'll make a huge table but at least i'll keep referential
integrity if someone changes an RO number in the "master" table...
the data wont be lost
and i'll just filter it by RO when ever i need to see only a
single type

thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top