Listbox problem

G

Guest

Hello
I'm not sure if I should give up trying to find an answer here...or just keep posting my problem..

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!
Ambe

Private Sub butRetrieve_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butRetrieve.Clic

If txtCPMain.Text <> "" The

get_specific_CP(

Els

get_all_CPs(

End I

End Su

*

Sub get_specific_CP(

lBoxCP.DataSource = Nothin

lBoxCP.Items.Clear(

lBoxCP.Refresh(


DsCP1.Clear(

SqlDA_CP.Fill(DsCP1

Dim dtbCP As DataTabl

dtbCP = DsCP1.Tables(0

Dim dtvCP As New DataView(dtbCP

dtvCP.RowFilter = "STR_CUTTING_PERMIT = '" & txtCPMain.Text & "'

lBoxCP.DataSource = dtvC

lBoxCP.DisplayMember = "STR_CUTTING_PERMIT

fill_all_textfields(

End Su

*

Private Sub get_all_CPs(

lBoxCP.DataSource = Nothin

lBoxCP.Items.Clear(

lBoxCP.Refresh(

DsCP1.Clear(

SqlDA_CP.Fill(DsCP1

lBoxCP.DataSource = DsCP1.Tables(0

lBoxCP.DisplayMember = "STR_CUTTING_PERMIT

End Su
 
C

CJ Taylor

are you sure your row filter is working correctly? the only thing I could
see is that yoru dataview isn't working, can you check to see that it has
row values.

-CJ

amber said:
Hello,
I'm not sure if I should give up trying to find an answer here...or just keep posting my problem...

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_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles butRetrieve.Click
 
G

Guest

Thanks for the reply CJ
Yes, the filter is working properly. All the correct data is shown...it's just that the items in the listbox are not visible..
I've been baffled by this for a while...and I'm not sure what to do
I've tried starting all over again...no luck
Ambe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top