Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combos and listboxes

Status
Not open for further replies.

technohead

Technical User
Jan 12, 2002
64
US
Hi
i just want to make the text in a list box and combo box to be blank when i return to the page if something has already been entered on it.
i thought what i have below would work but it brings me to the click event of both of them. I dont want that to happen.

could anyone tell me why it does this, or whats the right way to make the boxes blank.

frmmain1.cbocusno.ListIndex = -1
frmmain1.listsamename.Text = ""

Thanks
 
The clear method clears the lists...

frmmain1.cbocusno.clear
frmmain1.listsamename.clear

hope this helps.
 
i dont want to actually clear them just when i return to the page that what was previously there will not be still in the combo and listbox.

hope this is a bit clearer,
thanks
 
frmmain1.cbocusno.ListIndex = -1
frmmain1.listsamename.ListIndex = -1

A click event will be triggered. You must either ignore it when ListIndex < 0 or set a Form Level variable that is checked in the click event.
Private mblnClearingList As Boolean
'....
mblnClearingList = True
frmmain1.cbocusno.ListIndex = -1
frmmain1.listsamename.ListIndex = -1
mblnClearingList = fase
...
Private Sub cbocusno_click()
if mblnClearingList Then Exit Sub
...
End Sub

Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
make sure you have a null string (&quot;&quot;) as the first entry in the list box and set the listindex=0. For the combo box, just set text to &quot;&quot;

List1.AddItem &quot;&quot;, 0

Combo1.Text = &quot;&quot;
List1.ListIndex = 0

Also make sure the &quot;style&quot; property is 0 for the combo box.
 
this is the way i am adding the items to the listbox.

listsamename.AddItem (datname.Recordset.Fields(&quot;Address&quot;).Value)

so would you set your null string like this?? or what is the right way. i tried this one but it does'nt work

listsamename.AddItem (datname.Recordset.Fields(&quot;&quot;).Value + &quot; , &quot; + adocushis.Recordset.Fields(&quot;Address&quot;).Value)



thanks again
 
To put the null string in as the first entry, just
listsamename.AddItem &quot;&quot;, 0
You can do this at any time...when you start building the list, or later after you've already built it. The 0 tells AddItem to make this the first entry in the list, it will insert it before the current list of entries.

To clear the boxes upon reentry, run the other 2 commands.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top