Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to clone forms

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
I have an application with 10 input forms that are each different. The user must be able to have the ability to have multiple instances of each of the forms. i.e. Form1 as many times as they want. I have used this code behind a command button to launch a "clone" of the form that was requested for duplication.

Dim frmAA4561 As Form
Set frmAA4561 = New frmAA4561
frmAA4561.Show

frmAA4561 is the original form and also will duplicate itself with this code. The question that I have is how can I differentiate between frmAA4561 and its clone? Any help would be greatly appreciated.
 
After creating the 'clone', you couuld place some kind of unique identifier in the tag property of the form:

lFormCount = lFormCount + 1
frmAA4561.Tag = lFormCount

Then when you need to identify the form, use the tag.
-Chris Didion
Matrix Automation, MCP
 
Have you thought about creating an array of forms
for each form you want to clone?

e.g.

' This code in a module
Option Explicit

' Create an array for each of your forms
' e.g. in this case, Form1, Form2, Form3
Public Form1Clone() As New Form1
Public Form2Clone() As New Form2
Public Form3Clone() As New Form3


Public Sub CloneForm(FrmToClone As Variant)
Static CloneCount As Integer

CloneCount = CloneCount + 1
ReDim Preserve FrmToClone(CloneCount)

MsgBox UBound(FrmToClone)
End Sub

' This code in the command button of each form
Private Sub Command1_Click()
' in Form2, use Form2Clone, Form3 - Form3Clone etc.
CloneForm Form1Clone
End Sub


Sorry, didn't have time to test this properly,
I'm off for the weekend.
Hope it helps
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top