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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perplexing Problem with setting up dynamic forms 1

Status
Not open for further replies.

MrMoocow

Programmer
May 19, 2001
380
US
Ok,
I have a form that I need to load and give it a "index" based on a ID. So I made a array of objects: but since I can't set an array to an object, I have to set individual ones to the form inquestion.

Recap:
Need to load a form and assasign it a number,

Then need to be able to search through the create forms for the assigned numbers.

The Numbers are not in order.

Any Ideas? Brad,
Hey! email me any time! Bradsvb@yahoo.com
 
Add a .bas module, 2 forms to a project. add 3 command buttons & a list box to form1.
Command1 creates 3 new form2s.
Command2 lists the .Tag property (this would be your ID, or you could use the Key property of the collection) for each form in the collection
Command 3 gets rid of the collection.

.bas module
Option Explicit

Public colForms As New Collection

form1:
Option Explicit

Private Sub Command1_Click()
Dim frmTemp As Form2
Dim i As Integer
For i = 1 To 3
Set frmTemp = New Form2
Load frmTemp
frmTemp.Tag = i
colForms.Add frmTemp, "A" & i
Set frmTemp = Nothing
Next



End Sub


Private Sub Command2_Click()
Dim frmTemp As Form2
Dim i As Integer
For i = 1 To 3
Set frmTemp = colForms.Item(i)
List1.AddItem frmTemp.Tag
Next
Set frmTemp = Nothing
End Sub

Private Sub Command3_Click()
dim i as Integer

For i = 1 to 3
colForms.Remove colForms.Count
next
Set colForms = Nothing

End Sub
Tim

Remember the KISS principle:
Keep It Simple, Stupid! :cool:
 
wow,
Tim I have just one word "Thanks", This is one of the most clear examples I've gottent,

For you a star:
Thanks Brad,
Hey! email me any time! Bradsvb@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top