I'm working on creating a sort of virtual seating chart for use with large numbers of people in various amounts. I would like to set up the code so that at run-time a small command button is created for every seat in the room. I found code to do this using the CreateForm method but I need this to work in an existing form. Also, the code currently makes a form in design view but I need it to be in a running form view. Here is the code I am currently using;
Does any one have any ideas on how to dynamically create controls at runtime? Would ActiveX controls be more cooperative? Any help would be appreciated. Thanks
Code:
Set frm = CreateForm()
intHeight = 0.25 * adhcTwipsPerInch
intWidth = 0.3 * adhcTwipsPerInch
intGap = 0.03 * adhcTwipsPerInch
For intI = 1 To 6
For intJ = 1 To 7
intCount = intCount + 1
With CreateControl(FormName:=frm.Name, ControlType:=acCommandButton, _
Section:=acDetail, Left:=intJ * (intWidth + intGap), Top:=intI * (intHeight + _
intGap))
.Name = "cmd" & Format(intI, "00") & Format(intJ, "00")
.Height = intHeight
.Width = intWidth
.Caption = intCount
End With
Next intJ
Next intI