-
I'm trying working with a collection. Each item I add to a collection has three textboxes of info and text1 is added to a listbox. I'm trying to figure out how, when I click on a name in the list box to show all three textboxes of info for that item. I hope I made that clear enough. This is the first collection I've used.
Thanks,
JO
-
<?>
How are you passing the values and how do you want them returned?
Perhaps your code would help get an answer.
-
Don't really have any code yet, Im not sure how to start this.
There are two forms:
Form1 Code:
Private Account As Collection
Private Sub Form_Load()
Set Account = New Collection
End Sub
Private Sub cmdAdd_Click()
Dim frmAccount As New frmAccount
frmAccount.Show
End Sub
Private Sub cmdExit_Click()
End
End Sub
Form2(frmAccount) Code:
Private Sub Command1_Click()
Account.Add (Text1)
Form1.lst1.AddItem (frmAccount.Text1)
End Sub
-
<?>
Based on what you've given here is my version of what you want to happen..However, you haven't said anything about the other 2 textboxes.
Code:
'add a bas module and put this in it
Option Explicit
Public Account As Collection
'************************************************
'this code goes in form1
'form1 has a listbox, 3 textboxes, 2 command buttons
'list1, command1, cmdExit, text1, text2,text2
Option Explicit
Public Account As Collection
Private Sub Command1_Click()
Form1.Visible = False
frmAccount.Visible = True
End Sub
Private Sub cmdExit_Click()
Dim Form As Form
For Each Form In Forms
Unload Form
Set Form = Nothing
Next Form
End Sub
'***************************************************
'form2 has 2 command buttons,
'command1, command2
Private Sub Command1_Click()
'add the text of form1 to the collection account
'add the 1st item of the collection to the listbox on form1
Account.Add Form1.Text1
Form1.List1.AddItem Account(1)
End Sub
Private Sub Command2_Click()
'move from form to form
frmAccount.Visible = False
Form1.Visible = True
End Sub
Private Sub Form_Load()
'set the collection and add text to form1.textbox
Set Account = New Collection
Form1.Text1 = "Help Me Out"
End Sub