|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
matching property to array referenceAm using two forms. Form1 accepts entry that populates an array of type: studentsarr(arrelement).studentName = txtStudentName.Text studentsarr(arrelement).studentForm = cboForm.Text etc. Works fine. (arrelement incremented for next entry). StudentName then populates a combobox in form2 For arrelement = 1 To 10 cboSelectStudent.AddItem studentsarr(arrelement).studentName Next arrelement also fine. I want to use the selection in the combo to fill in the rest of the form2 lblForm lblAge = 'to match the array reference of the combo entry Have tried lblForm.caption = studentsarr(arrelement).studentForm but can't get (arrelement) to match the arrelement in the combo. Is this is scope issue? Any help appreciated. Thanks Mick
Show quote
Hide quote
"Mick Whyte" <mick.wh***@gmail.com> wrote in message You lost me beyond this point.news:1138822345.835300.76360@g14g2000cwa.googlegroups.com... > Hi > > Am using two forms. Form1 accepts entry that populates an array of > type: > > studentsarr(arrelement).studentName = txtStudentName.Text > studentsarr(arrelement).studentForm = cboForm.Text > > etc. Works fine. (arrelement incremented for next entry). > > StudentName then populates a combobox in form2 > > For arrelement = 1 To 10 > cboSelectStudent.AddItem studentsarr(arrelement).studentName > > Next arrelement > > > also fine. > > I want to use the selection in the combo to fill in the rest of the > form2 If cboSelectStudent is on Form2, you should be able to say: cboSelectStudent.ListIndex = arrelement Regarding scope: Unless 'studentsarr' is declared Public in a bas module, you'll have to pass the value as an argument to that form (hard to tell exactly how things are working there).... or declare it Public in the form and prefix the assignment with the form name... like Form1.studentsarr(arrelement).studentName = "blah" ....and, if 'studentsarr' is a UDT and not a class, you may have other issues to deal with. -- Ken Halter - MS-MVP-VB - Please keep all discussions in the groups.. DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm
Show quote
Hide quote
"Mick Whyte" <mick.wh***@gmail.com> wrote in message Try lblForm.caption = studentsarr(cboSelectStudent.ListIndex).studentFormnews:1138822345.835300.76360@g14g2000cwa.googlegroups.com... > Hi > > Am using two forms. Form1 accepts entry that populates an array of > type: > > studentsarr(arrelement).studentName = txtStudentName.Text > studentsarr(arrelement).studentForm = cboForm.Text > > etc. Works fine. (arrelement incremented for next entry). > > StudentName then populates a combobox in form2 > > For arrelement = 1 To 10 > cboSelectStudent.AddItem studentsarr(arrelement).studentName > > Next arrelement > > > also fine. > > I want to use the selection in the combo to fill in the rest of the > form2 > > lblForm > lblAge = 'to match the array reference of the combo entry > > Have tried > > lblForm.caption = studentsarr(arrelement).studentForm > > but can't get (arrelement) to match the arrelement in the combo. > > Is this is scope issue? > > Any help appreciated. > > Thanks > > Mick > or, better still have a look at the IemData property of the combo box |
|||||||||||||||||||||||