Hello,
I'm having problems with a listbox...
I have a listbox that is populated when a user presses a button
(retrieve). There is a textbox on the form, and if the textbox is left
blank, and the user presses the button, all records show in the listbox.
If the user enters a specific item into the textbox, then presses the
button, only that record shows in the listbox. There are fields on the
form which are populated by data associated with what is selected in the
listbox.
All this works great...my problem is this:
The first time 'retrieve' is clicked, it works great, but then, if
something else is entered into the textbox, or it is cleared to retrieve
all records, when the button is clicked, the listbox doesn't display
it's contents.
The data is there...all fields on the form are filled in correctly, and
you can even click on the list box to change what is selected, you just
can't see anything in the list box....
I'm baffled.
I'm pasting my code below.
Sorry this is so lengthy! Thanks in advance!!
Amber
Private Sub butRetrieve_Cli ck(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles butRetrieve.Cli ck
If txtCPMain.Text <> "" Then
get_specific_CP ()
Else
get_all_CPs()
End If
End Sub
**
Sub get_specific_CP ()
lBoxCP.DataSour ce = Nothing
lBoxCP.Items.Cl ear()
lBoxCP.Refresh( )
DsCP1.Clear()
SqlDA_CP.Fill(D sCP1)
Dim dtbCP As DataTable
dtbCP = DsCP1.Tables(0)
Dim dtvCP As New DataView(dtbCP)
dtvCP.RowFilter = "STR_CUTTING_PE RMIT = '" & txtCPMain.Text & "'"
lBoxCP.DataSour ce = dtvCP
lBoxCP.DisplayM ember = "STR_CUTTING_PE RMIT"
fill_all_textfi elds()
End Sub
**
Private Sub get_all_CPs()
lBoxCP.DataSour ce = Nothing
lBoxCP.Items.Cl ear()
lBoxCP.Refresh( )
DsCP1.Clear()
SqlDA_CP.Fill(D sCP1)
lBoxCP.DataSour ce = DsCP1.Tables(0)
lBoxCP.DisplayM ember = "STR_CUTTING_PE RMIT"
End Sub
I'm having problems with a listbox...
I have a listbox that is populated when a user presses a button
(retrieve). There is a textbox on the form, and if the textbox is left
blank, and the user presses the button, all records show in the listbox.
If the user enters a specific item into the textbox, then presses the
button, only that record shows in the listbox. There are fields on the
form which are populated by data associated with what is selected in the
listbox.
All this works great...my problem is this:
The first time 'retrieve' is clicked, it works great, but then, if
something else is entered into the textbox, or it is cleared to retrieve
all records, when the button is clicked, the listbox doesn't display
it's contents.
The data is there...all fields on the form are filled in correctly, and
you can even click on the list box to change what is selected, you just
can't see anything in the list box....
I'm baffled.
I'm pasting my code below.
Sorry this is so lengthy! Thanks in advance!!
Amber
Private Sub butRetrieve_Cli ck(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles butRetrieve.Cli ck
If txtCPMain.Text <> "" Then
get_specific_CP ()
Else
get_all_CPs()
End If
End Sub
**
Sub get_specific_CP ()
lBoxCP.DataSour ce = Nothing
lBoxCP.Items.Cl ear()
lBoxCP.Refresh( )
DsCP1.Clear()
SqlDA_CP.Fill(D sCP1)
Dim dtbCP As DataTable
dtbCP = DsCP1.Tables(0)
Dim dtvCP As New DataView(dtbCP)
dtvCP.RowFilter = "STR_CUTTING_PE RMIT = '" & txtCPMain.Text & "'"
lBoxCP.DataSour ce = dtvCP
lBoxCP.DisplayM ember = "STR_CUTTING_PE RMIT"
fill_all_textfi elds()
End Sub
**
Private Sub get_all_CPs()
lBoxCP.DataSour ce = Nothing
lBoxCP.Items.Cl ear()
lBoxCP.Refresh( )
DsCP1.Clear()
SqlDA_CP.Fill(D sCP1)
lBoxCP.DataSour ce = DsCP1.Tables(0)
lBoxCP.DisplayM ember = "STR_CUTTING_PE RMIT"
End Sub