Section number - createcontrol()

S

sumesh

I am creating a form at runtime. I want to create two
controls in the form footer section. So, I changed the
value "2" in Createcontrol method but I am getting an
error message not a valid section number.

It is accepting only "0" (i.e, detail section)

What will make the controls to display at form footer.

Code it attached.

Thanks

Regards
Sumesh

Sub NewControls()
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

' Create new form with Orders table as its record
source.
Set frm = CreateForm
frm.RecordSource = "Orders"
' Set positioning values for new controls.
intLabelX = 100
intLabelY = 100
intDataX = 1000
intDataY = 100
' Create unbound default-size text box in detail
section.
Set ctlText = CreateControl(frm.Name, acTextBox,
2, "", "", _
intDataX, intDataY)
' Create child label control for text box.
Set ctlLabel = CreateControl(frm.Name, acLabel, , _
ctlText.Name, "NewLabel", intLabelX, intLabelY)
' Restore form.
DoCmd.Restore
End Sub
 
M

Marshall Barton

sumesh said:
I am creating a form at runtime. I want to create two
controls in the form footer section. So, I changed the
value "2" in Createcontrol method but I am getting an
error message not a valid section number.

It is accepting only "0" (i.e, detail section)

What will make the controls to display at form footer.

You haven't told the form to display its header or footer
sections so they don't exist to place controls into.

Sub NewControls()
. . .
' Create new form with Orders table as its record
source.
Set frm = CreateForm
Docmd.RunCommand acCmdFormHdrFtr
. . .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top