Can you create a table from a form in Access 2002?

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

tori712

Thread Starter
Joined
Jul 3, 2007
Messages
1
Hello. I created a new database modeling a form in Access 2002 from another database program that I have, yet I have not added any tables yet. I have always created forms, using a wizard, from existing tables in Access, yet this time, because there was so much needed on the form, I have done it backwards and I would like to now create the tables for it.

The problem is, either it doesn't seem to be possible, or I just can't find the way to do it.

Can anyone help me???
 

OBP

Joined
Mar 8, 2005
Messages
19,895
As far as I know there is no automatic way to create a Table from an Unbound Form.
It could probably be done using VBA, but the amount of Programming involved is likely to be more than just creating it manually in design view.
One way to help you create the Table manually would be to use the Access Documenter to print out the Design Specification of your Form.
I am not sure that the way that you have gone about it is the is the best way though.
By just creating a form to enter the data may lead you to put all the data in one Table when in fact it should be split up between related tables.
I can help you if you think that you need it.
 
Joined
Sep 4, 2003
Messages
4,916
Open the database and press ALT+F11 to open the VBA editor. Click TOOLS --> REFERENCES and set reference to Microsoft DAO objects 3.6 click OK. Next copy and paste the code below to your button click event or other form event of your choice. The example code below will create the table with two fields and then add one record to it. If you need more help please post your database and/or form and provide a detailed explaination of what you would like to happen.

Code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim tdfNew As TableDef
Dim fldNew As Field

'--- set a reference to the database
Set db = CurrentDb

'--- create the table
Set tdfNew = db.CreateTableDef("MyNewTable")

'--- add integer field
Set fldNew = tdfNew.CreateField("MyNewIntField", dbInteger)
'--- save the new field
tdfNew.Fields.Append fldNew

'--- add text field (length 20)
Set fldNew = tdfNew.CreateField("MyNewTextField", dbText, 20)
'--- save the new field
tdfNew.Fields.Append fldNew

'--- save the new table design
db.TableDefs.Append tdfNew

'---Initialize your recordset
Set rs = CurrentDb.OpenRecordset("MyNewTable", dbOpenDynaset)
' Add New Record
rs.AddNew
rs.Fields(0).Value = 1
rs.Fields(1).Value = "FirstRecord"
rs.Update

'--- Clear memory
Set fldNew = Nothing
Set tblNew = Nothing
Set db = Nothing
Regards,
Rollin
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top