New topic: checkbox issue
<http://forums.realsoftware.com/viewtopic.php?t=47785> Page 1 of 1 [ 5 posts ] Previous topic | Next topic Author Message azrael2000 Post subject: checkbox issuePosted: Sat May 04, 2013 2:04 pm Joined: Fri Oct 13, 2006 3:18 pm Posts: 327 Hi All. Have a question about checkboxes, that hopefully someone can explain to me. In my program, I have checkboxes that can be selected to allow the user to assign a person to different events. When I have my program run, and CLOSE the window with the entries in it, everything works normally. If I leave the window open, to allow the user to repeat the action of adding users, every user after the first one is entered in ALL of the events. I unselect the checkboxes using the following code: textRiderName.text = "" textHorseName.text = "" checkIsExhibitionOnly.state = CheckBox.CheckedStates.Unchecked for i = 0 to 1 radioIsMember(i).Value = false next i for i = 0 to 3 radioWhatDivision(i).value = false next i //turn off the checkboxes for i = 0 to 7 'checkWhatClass(i).value = false checkWhatClass(i).state = CheckBox.CheckedStates.Unchecked //this is what actually unchecks the checkboxes as far as the program is concerned. next i Why do I have to close the window? Is there something I am NOT doing? Regards Top npalardy Post subject: Re: checkbox issuePosted: Sat May 04, 2013 2:47 pm Real Software Engineer Joined: Sat Dec 24, 2005 8:18 pm Posts: 7821 Location: Canada, Alberta, Near Red Deer This code certainly seems to set the UI to the right state. What does your code to add a person to an event look like ? There has to be a reasonable explanation of whats going on. _________________ Norman Palardy (Real Software) Top azrael2000 Post subject: Re: checkbox issuePosted: Sat May 04, 2013 6:51 pm Joined: Fri Oct 13, 2006 3:18 pm Posts: 327 Hi. Thanks for the reply. Here is the code for adding a user, with the checkboxes they have chosen. (I know it right now is VERY BADLY done... but I clean everything up once it is doing what I want.... if db.Connect() then //ok, I've connected to the database, let's tell everyone //for troubleshooting only MsgBox "Connected to the server." //ok. //the entry form has been filled in. //we will have to now fill in the database. In this case, because the rider can have different horses and in different classes //we will have to walk through, and add on entry for each checkbox selected in the class (whatClass...) //Let's create our insert statement.. //we will put it in a variable to make entry easier, as the statement itself does not change. 'sqlinsert = "insert into entry (rider,horse,member,exhibition,division,class) values ('"+textRiderName.text+"','"+textHorseName.text+"','"+memberClassification+"','"+theexhibition+"','"+theDivision+"','"+division+"')" ''MsgBox "The value of sqlinsert is "+sqlinsert 'db.SQLExecute( sqlinsert) 'db.Commit for i = 0 to checkBoxCount-1 // how many check boxes were selected. if barrels = TRUE then //they want barrels, change division, and write the information division = "barrels" sqlinsert = "insert into entry (rider,horse,member,exhibition,division,class) values ('"+textRiderName.text+"','"+textHorseName.text+"','"+memberClassification+"','"+theexhibition+"','"+theDivision+"','"+division+"')" 'MsgBox "The value of sqlinsert is "+sqlinsert db.SQLExecute(sqlinsert) db.commit //now that the barrels entry has been done, set its value to false so it won't be added again, hopefully... barrels = False else // end if if poles = TRUE then //they want barrels, change division, and write the information division = "poles" sqlinsert = "insert into entry (rider,horse,member,exhibition,division,class) values ('"+textRiderName.text+"','"+textHorseName.text+"','"+memberClassification+"','"+theexhibition+"','"+theDivision+"','"+division+"')" 'MsgBox "The value of sqlinsert is "+sqlinsert db.SQLExecute(sqlinsert) db.commit //now that the barrels entry has been done, set its value to false so it won't be added again, hopefully... poles = False else // end if if keyhole = TRUE then //they want barrels, change division, and write the information division = "keyhole" sqlinsert = "insert into entry (rider,horse,member,exhibition,division,class) values ('"+textRiderName.text+"','"+textHorseName.text+"','"+memberClassification+"','"+theexhibition+"','"+theDivision+"','"+division+"')" 'MsgBox "The value of sqlinsert is "+sqlinsert db.SQLExecute(sqlinsert) db.commit //now that the barrels entry has been done, set its value to false so it won't be added again, hopefully... keyhole = False else // end if if dashForCash = TRUE then //they want barrels, change division, and write the information division = "Dash For Cash" sqlinsert = "insert into entry (rider,horse,member,exhibition,division,class) values ('"+textRiderName.text+"','"+textHorseName.text+"','"+memberClassification+"','"+theexhibition+"','"+theDivision+"','"+division+"')" 'MsgBox "The value of sqlinsert is "+sqlinsert db.SQLExecute(sqlinsert) db.commit //now that the barrels entry has been done, set its value to false so it won't be added again, hopefully... dashForCash = False else // end if if flags = TRUE then //they want barrels, change division, and write the information division = "flags" sqlinsert = "insert into entry (rider,horse,member,exhibition,division,class) values ('"+textRiderName.text+"','"+textHorseName.text+"','"+memberClassification+"','"+theexhibition+"','"+theDivision+"','"+division+"')" 'MsgBox "The value of sqlinsert is "+sqlinsert db.SQLExecute(sqlinsert) db.commit //now that the barrels entry has been done, set its value to false so it won't be added again, hopefully... flags = False else // end if if threeDbarrels = TRUE then //they want barrels, change division, and write the information division = "three d barrels" sqlinsert = "insert into entry (rider,horse,member,exhibition,division,class) values ('"+textRiderName.text+"','"+textHorseName.text+"','"+memberClassification+"','"+theexhibition+"','"+theDivision+"','"+division+"')" 'MsgBox "The value of sqlinsert is "+sqlinsert db.SQLExecute(sqlinsert) db.commit //now that the barrels entry has been done, set its value to false so it won't be added again, hopefully... threeDbarrels = False else // end if if pickUpRescue = TRUE then //they want barrels, change division, and write the information division = "Pick up and Rescue" sqlinsert = "insert into entry (rider,horse,member,exhibition,division,class) values ('"+textRiderName.text+"','"+textHorseName.text+"','"+memberClassification+"','"+theexhibition+"','"+theDivision+"','"+division+"')" 'MsgBox "The value of sqlinsert is "+sqlinsert db.SQLExecute(sqlinsert) db.commit //now that the barrels entry has been done, set its value to false so it won't be added again, hopefully... pickUpRescue = False else // end if if openRelay = TRUE then //they want barrels, change division, and write the information division = "Open Relay" sqlinsert = "insert into entry (rider,horse,member,exhibition,division,class) values ('"+textRiderName.text+"','"+textHorseName.text+"','"+memberClassification+"','"+theexhibition+"','"+theDivision+"','"+division+"')" 'MsgBox "The value of sqlinsert is "+sqlinsert db.SQLExecute(sqlinsert) db.commit //now that the barrels entry has been done, set its value to false so it won't be added again, hopefully... openRelay = False else // end if next i Regards Top timhare Post subject: Re: checkbox issuePosted: Sun May 05, 2013 12:01 am Joined: Fri Jan 06, 2006 3:21 pm Posts: 12295 Location: Portland, OR USA You're using a bunch of boolean variables which are not directly tied to the checkboxes. My guess is that you're resetting the checkboxes, but not resetting those variables. Or, you're failing to load the variables from the checkboxes before you call this code. Top azrael2000 Post subject: Re: checkbox issuePosted: Sun May 05, 2013 6:17 am Joined: Fri Oct 13, 2006 3:18 pm Posts: 327 Hi Mr. Hare. Yes the variables are initially set to false, in the module I use, when the program starts. I reset the variable to false after the program runs through the ungainly if statements I have (yes I will be changing it to something more elegant when I get everything operating 'normally') Regards Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 5 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
