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!

Seeing multiples in DTC drop-down box

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello.

I'm having a problem with the additem method. In order to add an item to my drop-down I use the following code:

cboNew.additem "Please choose number",-1, -1

After making a selection I go back to make another. This is when I notice my "Please choose number" appearing twice....if I continue in this manner, it keeps multiplying. What am I doing wrong???

Thanks for your help.
Rene
 
Hi Metka. Here's the sub w/ my code where I'm using it:

Sub btnNew_onclick()
strMonth="Select Month"
lblMonth.setCaption(strMonth)
cboMonthAdd.additem "Select Month", -1,-1
cboMonthAdd.disabled=false
tblSchedEvents.addRecord
txtMonth.value = cboMonthAdd.getValue()
intR=1
Count.value=intR
End Sub

Thanks for helping.

Rene
 
My apologies...I gave you the wrong event. I see multiples after reselecting my drop-down. The onchange event for it is as follows:

Sub cboMonthAdd_onchange()
strCap="to insert Nalc..."
lblEdit.setCaption()=strCap
datebox.disabled=true
edatebox.disabled=true
txtEvent.disabled=true
location.disabled=true
Team.disabled=true
Status.disabled=true
lblEdit.show
lblSelect.show
cboNalc.show
tblSchedEvents.open
tblSchedEvents.addRecord
txtMonth.value = cboMonthAdd.getValue()
intR=1
Count.value=intR
End Sub

Thanks again for your help.
Rene
 

Hi Rene,
i still don't see what is wrong. the code you posted shouldn't create duplicates. do you use "additem" anywhere else (thisPage_onenter event or somplace else)? in your first post you said that after you make a selection you go to add another item? maybe the problem is there. what are you trying to do on this page?
sorry i can't be more helpfull. did you try debugging the code to see where it adds duplicate values?
 
Most DTC controls remember their state - Browse to the page and view-source, look at the botom of the page and you will see hidden fields for each page control. The complete dropdown list is stored here, and allows the combo to be re-generated without going back to a recordset. In ASP.NET, this is called 'ViewState'.

If you have an addItem, it should only be called once - so if it is in the thisPage_onenter() code then...
if thisPage.firstEntered then
cmbMyCombo.addItem ...
end if
[assuming you have added a PageObject DTC] (Content Management)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top