items in listbox not visible

G

Guest

Hello
I have a listbox that is populated when a user hits a 'retrieve' button. If data is entered in a text field before button in
pressed, then one specific item is displayed in the listbox. If nothing is entered into the textbox, then pressing the button
will fill the list box with all possible items. There are multiple text boxes on the form that are populated using the criteria
selected in the listbox
This works great, but, if I enter a specific item first, it is displayed correctly, then, if I enter another item, it doesn't display
in the textbox. (although it works...all associated data is filled in properly)
And if I (after entering a specific value) remove text in the textbox, and press 'retrieve' - the listbox stays blank, but the data is there...I can click in the listbox, and the associated data is still displaying/changing on the form.
It is as though the visibility is set to false....but it isn't..
Any suggestions?
Thanks
Amber
 
L

Les Smith

Amber
If you want to post the code, if it is not too extensive, I could take a
look at it, but it's hard to tell the problem w/o the code.
Les
http://www.KnowDotNet.com

amber said:
Hello,
I have a listbox that is populated when a user hits a 'retrieve' button.
If data is entered in a text field before button in
pressed, then one specific item is displayed in the listbox. If nothing is
entered into the textbox, then pressing the button
will fill the list box with all possible items. There are multiple text
boxes on the form that are populated using the criteria
selected in the listbox.
This works great, but, if I enter a specific item first, it is displayed
correctly, then, if I enter another item, it doesn't display
in the textbox. (although it works...all associated data is filled in properly).
And if I (after entering a specific value) remove text in the textbox, and
press 'retrieve' - the listbox stays blank, but the data is there...I can
click in the listbox, and the associated data is still displaying/changing
on the form.
 
G

Guest

Thanks for the reply
The code is quite extensive..
Basically I have a button, when pushed it checks for a value in the textbox: txtCPMain...if there is a value...runs getSpecificCP()...if no value, runs getAllCPs().
I've pasted the relevant code below. Note that when the index of the lBoxCP changes, it calls fill_all_text_fields(
Thanks for your help

Sub get_specific_CP(

lBoxCP.DataSource = Nothin
lBoxCP.Items.Clear(
lBoxCP.Refresh(

Dim CI As String = txtCPMain.Tex
Dim ConStr As String = "workstation id=LAPTOPAMBER;packet size=4096;integrated security=SSPI;initial catalog=fsAbitibi;persist security info=False
Dim dssCP As DataSet = SqlHelper.ExecuteDataset(ConStr, CommandType.Text,
"SELECT ID_CUTTING_PERMIT, STR_CUTTING_PERMIT, STR_FOREST_DISTRICT, STR_FOREST_REGION, STR_TSA, STR_LICENSEE, STR_LICENSE_NO, STR_OPERATING_AREA, STR_TIMBER_MARK, STR_CATEGORY, DTM_FORECAST, STR_EMPLOYEE, DTM_COMPLETE, STR_SIGN_OFF_BY, DTM_SIGN_OFF, STR_PEER_REVIEW, DTM_PEER_REVIEW, STR_SIGN_OFF_STATUS, STR_SIGN_OFF_COM FROM TDT_CUTTING_PERMIT WHERE STR_CUTTING_PERMIT = '" & CI & "'"

lBoxCP.DataSource = dssCP.Tables(0
lBoxCP.DisplayMember = "STR_CUTTING_PERMIT

fill_all_textfields(

End Su


Private Sub get_all_CPs(

lBoxCP.DataSource = Nothin
lBoxCP.Items.Clear(
lBoxCP.Refresh(

Dim ConStr As String = "workstation id=LAPTOPAMBER;packet size=4096;integrated security=SSPI;initial catalog=fsAbitibi;persist security info=False
Dim dsACP As DataSet = SqlHelper.ExecuteDataset(ConStr, CommandType.Text,
"SELECT ID_CUTTING_PERMIT, STR_CUTTING_PERMIT, STR_FOREST_DISTRICT, STR_FOREST_REGION, STR_TSA, STR_LICENSEE, STR_LICENSE_NO, STR_OPERATING_AREA, STR_TIMBER_MARK, STR_CATEGORY, DTM_FORECAST, STR_EMPLOYEE, DTM_COMPLETE, STR_SIGN_OFF_BY, DTM_SIGN_OFF, STR_PEER_REVIEW, DTM_PEER_REVIEW, STR_SIGN_OFF_STATUS, STR_SIGN_OFF_COM FROM TDT_CUTTING_PERMIT"

lBoxCP.DataSource = dsACP.Tables(0
lBoxCP.DisplayMember = "STR_CUTTING_PERMIT

End Su

Private Sub fill_all_textfields(
'note: the text box containing txtCPID is hidden under the retrieve butto

Dim drv As DataRowView = lBoxCP.SelectedIte
'the fIRST 2 are declared as variables first simply because I was following an exampl
'doesn't seem to be necessary, so the rest are directly linke
Dim strCPTXT As String = drv("STR_CUTTING_PERMIT"
Dim strCPID As String = drv("ID_CUTTING_PERMIT"

txtCPID.Text = strCPI
txtCP.Text = drv("STR_CUTTING_PERMIT").ToStrin
txtOArea.Text = drv("STR_OPERATING_AREA").ToStrin
txtForReg.Text = drv("STR_FOREST_REGION").ToStrin
txtForecast.Text = drv("DTM_FORECAST").ToStrin
txtPeerRev.Text = drv("STR_PEER_REVIEW").ToStrin
txtTMark.Text = drv("STR_TIMBER_MARK").ToStrin
txtTSA.Text = drv("STR_TSA").ToStrin

'Populate Submissions data bo

OleDbDataAdapter1.SelectCommand.Parameters("ID_CUTTING_PERMIT").Value = txtCPID.Tex
DsSub1.Clear(
OleDbDataAdapter1.Fill(DsSub1


End Sub
 

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

Similar Threads

Access Cannot select items in listbox 1
Listbox problem 2
Force Listbox 1
Listbox not clearing 3
Force Listbox to Refresh 5
textbox and listbox 6
Moving item from 1 listbox to another listbox 3
clearing a listbox 2

Top