Create A Table

TKnight

Registered User.
Local time
Today, 21:19
Joined
Jan 28, 2003
Messages
181
Hi, i'm trying to write a module that creates a form to store notes about all the forms in a database. I need it so that i can import it into any database and it will work. So far it works but only stores the last form name that it finds because i haven't based the form i've created on a table so it can't add a new record. Can anyone give me the code to create a table called "Form_Details" with two text fields ("Form_Name" and "Notes") so that I can finish it off, i tried stuff in the help (executing a CREATE sql) but didn't get very far, Thanks, Tom.


Here is the code i've got so far if it helps...

Option Compare Database
Dim obj As AccessObject, dbs As Object

Sub Form_Information()

Dim frm As Form
Dim ctl As Control
Dim intDataX As Integer, intDataY As Integer, twip As Integer
Dim strForm As String

Set dbs = Application.CurrentProject
twip = 567 'Enables lengths in cm
intDataX = 3 * twip
intDataY = 0.1 * twip
strForm = "Form_Details"

Set frm = CreateForm
With frm
.DefaultView = 1
.Section(acDetail).Height = 1000
End With 'creates continuous form
Set ctlText = CreateControl(frm.Name, acTextBox, , "", "", _
intDataX, intDataY)
Set ctlText = CreateControl(frm.Name, acTextBox, , "", "", _
intDataX, intDataY) 'Adds controls for form names and notes

DoCmd.Save acDefault, strForm
DoCmd.OpenForm strForm, acNormal 'saves and opens form in normal view

For Each obj In dbs.AllForms
Forms![Form_Details]![text0] = obj.Name
DoCmd.GoToRecord acDataForm, strForm, acNewRec
Next ' puts the name of each form in the text box created

End Sub
 
I believe this answers your question as it is stated, but I'm not sure if this is what you're looking for:

Code:
Public Sub CT()
Dim dbs As Database

    Set dbs = CurrentDb
    dbs.Execute "CREATE TABLE Form_Details (Form_Name TEXT, Notes MEMO)"

End Sub

Seems by your code you are creating a Form, not a table. Maybe it's just early for me and I'm not getting it ... :)
 
Thanks, thats great, i know it's wierd but it works!
 

Users who are viewing this thread

Back
Top Bottom