I just did this over the weekend. I am using an existing form and
opening it in design mode and then adding the controls based on data in
a table. You can also use CreateForm to start with a new form.
DoCmd.OpenForm "frmPanelRightTemplate", acDesign, , , , acHidden
Set db = CurrentDb
Set rs = db.OpenRecordset("qryRightPanelFastener")
'For each Right Panel fastener add a command button and set
properties
rs.MoveFirst
DoCmd.SetWarnings (off)
Do While Not rs.EOF
Set ctl = CreateControl("frmPanelRightTemplate",
acCommandButton, , , , rs![FastenerXCoordinate] * 1440,
rs![FastenerYCoordinate] * 1440)
ctl.Caption = rs![FastenerNumber]
ctl.Height = 0.275 * 1440
ctl.Width = 0.275 * 1440
ctl.FontSize = 7
ctl.TabStop = False
ctl.Name = "cmd" & rs![FastenerNumber]
'ctl.FontWeight = "bold"
rs.MoveNext
Loop
DoCmd.Save