I have a database that a user enters in info, then they have the option to retrieve it and edit it. But I have several ComboBox's that I use for faster entry that the user selects from.
Problem is I can't figure out how to get it to populate the data once it is retrieved and have it appear as the selected item from the drop down.
Note: I am storing the text of the Combobox in the sqlite db
Is there an easy way or will I have to figure out some sort of fancy if then statement (Help neede if that is the case)
Additionally, I have it so they can enter in their own data into the ComboBox, is there a way to make it so the data is then save as part of the combobox for future use? (So it then become one of the choices)
Here is my code
Problem is I can't figure out how to get it to populate the data once it is retrieved and have it appear as the selected item from the drop down.
Note: I am storing the text of the Combobox in the sqlite db
Is there an easy way or will I have to figure out some sort of fancy if then statement (Help neede if that is the case)
Additionally, I have it so they can enter in their own data into the ComboBox, is there a way to make it so the data is then save as part of the combobox for future use? (So it then become one of the choices)
Here is my code
Code:
--sListBox is the list of all the Games listed they can select from to edit --I-Genre1 is the ComboBox that is in question --genrel is the column in the sqlite db table --tbreturn is the row being selected for the sqlite db table function PopFields(sListBox) --Initialize local variables; local tbSel = ListBox.GetSelected(sListBox); local nRID = 0; --Check to see that an item was selected if tbSel then --Retrieve the data portion from the list box, this contains --the Record ID from the database sID = ListBox.GetItemData(sListBox, tbSel[1]); --Ensure that the variable is a number by using String.ToNumber nID = String.ToNumber(sID); --Now query the database using that Record ID local tbReturn = SQLite.QueryToTable(db, "SELECT * FROM games where ID = " .. nID); --If data is returned set populate the fields with the --appropriate information from the database if tbReturn and tbReturn.Rows > 0 then Input.SetText("I-Name", tbReturn.Data[1]["name"]); ------- ComboBox.SetSelected("I-Genre1", tbReturn.Data[1], genre1) ------- Input.SetText("I-Size", tbReturn.Data[1]["size"]); Paragraph.SetText("I-Requi", tbReturn.Data[1]["requi"]); Paragraph.SetText("I-Notes", tbReturn.Data[1]["notes"]); Input.SetText("I-Loc", tbReturn.Data[1]["loc"]); --Set the nRID variable to the Record ID of the selected entry nRID = nID; else --There was an error in retrieving the record from the database Dialog.Message("Error", "There was an error retrieving your information"); end else --No items were selected in the listbox. Dialog.Message("Error", "No item was selected."); end --return the blnEdit variable. return nRID; end
Comment