Passing data between forms...

  • Thread starter Thread starter Steven Smith
  • Start date Start date
S

Steven Smith

Help I've got a problem !

What I'm trying to do is in one event procedure in Form A
is to search an array list class for a match on one
element and display the results on Form B

I've got a similar but slightly more complex function
working perfectly inside Form A which goes something like
this:

\\\>

Private Sub cmdSearch_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) _
Handles cmdSearch.Click

Dim tempAlbum As New Album_Class

Select Case True
Case Me.cmbSearchOn.SelectedItem = "Genre"
For Each tempAlbum In myMusic
If tempAlbum.Genre =
Me.txtSearchCriteria.Text Then
Call display(tempAlbum)
End If
Next tempAlbum

end sub

Private Sub display(ByRef tempAlbum)

cmbGenre.SelectedItem = tempAlbum.Genre
txtAlbumName.Text = tempAlbum.AlbumName
txtArtistName.Text = tempAlbum.ArtistName
txtRecordLabel.Text = tempAlbum.RecordLabel
txtYear.Text = tempAlbum.Year

end sub

///>

^^^This simply searches the arraylist and display the
result as you would expect. However this one which is
trying to work between the 2 forms refuses to display any
results

\\\>

Private Sub txtArtistName_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) _
Handles txtArtistName.DoubleClick

Dim tempArtist As New Artist_Class

For Each tempArtist In myArtists
If tempArtist.ArtistName =
Me.txtArtistName.Text Then
Call display_artist(tempArtist)
End If
Next tempArtist

objArtistForm.ShowDialog()


End Sub


Private Sub display_artist(ByRef tempArtist)

objArtistForm.txtSingerName.Text =
tempArtist.ArtistName
objArtistForm.txtDateOfBirth.Text =
tempArtist.DateOfBirth
objArtistForm.txtDateOfDeath.Text =
tempArtist.DateOfDeath
objArtistForm.txtBiography.Text =
tempArtist.Biography

End Sub

///>

Can anyone see anything blatantly obvious that I might be
doing wrong ??
 
Ok just to narrow it down a bit for you guy's I dumped
the event procedure onto the second form and performed
the search on the arraylist that way and it does produce
the desired results, so my classes must be set properly
with correct names etc. So there definetly seems to be a
problem with passing it between the forms...
 
Finally figured this one out myself the value was
definetly getting lost between the forms, so what I done
was simply passed the value to the form through a
variable and performed the search on the arraylist
automatically in the form B's load event if a specific
criteria was met - easy when you know how, highly
distressing when you don't

Muuuuhaaaahaaaa.....!
 
Back
Top