How can I create a new form...

pjustin1

Registered User.
Local time
Today, 00:40
Joined
Nov 9, 2001
Messages
15
Hi,
I trying to create a new form using VBA and this the code below is what I had done...

But the form popup is in design view.. how can I make it to be in Form view?

Is the code correct? what else should I add or is there a shorter method? Thanks

Dim db As Database, newTable As TableDef, myFields As Field
Set db = CurrentDb

Set newTable = db.CreateTableDef(Me!Cust)
Set myFields = newTable.CreateField("Book Title", dbText)
newTable.Fields.Append myFields

Set myFields = newTable.CreateField("Retail Price", dbCurrency)
newTable.Fields.Append myFields
db.TableDefs.Append newTable

Dim frm As Form
Dim ctlLabel As Control, ctlText As Control
Dim intDataX As Integer, intDataY As Integer
Dim intLabelX As Integer, intLabelY As Integer

Set frm = CreateForm
frm.RecordSource = "BookInfo"
intLabelX = 100
intLabelY = 100
intDataX = 1000
intDataY = 100

Set ctlText = CreateControl(frm.Name, acTextBox, , "", "", _
intDataX, intDataY)
Set ctlLabel = CreateControl(frm.Name, acLabel, , ctlText.Name, _
"NewLabel", intLabelX, intLabelY)
DoCmd.Restore
 

Users who are viewing this thread

Back
Top Bottom