Hi everyone,
I have the code to create multiple instances of a form, maximum of 12. I would like these 12 forms to be temporary rename so I can use the "DoCmd.MoveSize" command to show each one of them to a particular place on the screen. When the user is done, delete the forms. So the name I want for these form could be as simple as Form1 to Form12. Please take note that not all of the form is created, it could be any number to a maximum of 12.
Here is the code:
I have the code to create multiple instances of a form, maximum of 12. I would like these 12 forms to be temporary rename so I can use the "DoCmd.MoveSize" command to show each one of them to a particular place on the screen. When the user is done, delete the forms. So the name I want for these form could be as simple as Form1 to Form12. Please take note that not all of the form is created, it could be any number to a maximum of 12.
Here is the code:
Code:
Function StackCompanyForms()
Const conSQL = "SELECT * FROM Companies Order By Company"
Dim dbs As DAO.Database, rst As DAO.Recordset
Dim n As Integer
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(conSQL)
Dim i As Integer
Do While Not rst.EOF
n = n + 1
Set frm = New Form_frmCompanies
colPopups.Add frm, frm.hwnd & n
frm.Caption = rst.Fields("Company")
frm.Filter = "CompanyID = " & rst.Fields("CompanyID")
frm.FilterOn = True
frm.Visible = True
DoCmd.MoveSize n * 360, n * 360
rst.MoveNext
Loop
End Function