View Full Version : Only add once
stickck
07-27-2006, 02:23 AM
Here is what i have.
for nRow = 1, tReport.Rows do
sLSU = tReport.Data[nRow]["ADPE_Account"]
ComboBox.AddItem("Plugin1", sLSU, "");
end
i'm about postal with this one. how can i prevent it from entering the same text twice. in the column ADPE_Account is a list of whos account the item is on. so the account names could be in that column a hundred times. how can i only have it enter the account name one time.
Chris
Intrigued
07-27-2006, 03:01 AM
Review this code I did here:
strSearchString = "Ace"
numIsFound = ComboBox.FindItem("ComboBox1", LB_ALLITEMS, LB_BYTEXTDATA, strSearchString)
if numIsFound == -1 then
ComboBox.AddItem("ComboBox1", strSearchString, "")
ComboBox.SetSelected("ComboBox1", 1)
end
stickck
07-27-2006, 04:14 AM
Thanks Intrigued! this what i did to it.
for nRow = 1, tReport.Rows do
sLSU = tReport.Data[nRow]["ADPE_Account"]
numIsFound = ComboBox.FindItem("Plugin1", LB_ALLITEMS, LB_BYTEXTDATA, sLSU)
if numIsFound == -1 then
ComboBox.AddItem("Plugin1", sLSU, "")
end
end
i was looking at just concating sLSU to itself each time and run a string.find on the new string to see if its a duplicate. i figured that would get messy. your way is much better.
Thanks again!
Chris
Intrigued
07-27-2006, 11:22 AM
Not a problem stickck, glad it "get-r-done" for ya.
:p
TJ_Tigger
07-29-2006, 06:55 PM
Chris,
Could you modify your query to return only the DISTINCT entries within a particular column?
SELECT Statement (http://www.sqlite.org/lang_select.html)
I don't know what you are ultimately trying to do but you could perform a
SELECT DISTINCT ADPE_Account from tablename
HTH
Tigg
stickck
07-29-2006, 08:49 PM
I run the query to create tReport table and then use that table several times throughout the project. I would just requery the DB but i'm trying to keep the queries to a minimal because there will be multiple users (Maybe 5 at a time) using this program at any given time.
That script i posted above works perfect. i also use something very similar for the HTML reports page also.
Thanks for the help. i might be able to use that in another place though.
If you want to see the project, here's the link
http://www.box.net/public/h6m5d5bryj It's in AMS 5 since that's what I have at work.
Chris
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.