
Quote from CSSystems on September 5, 2021, 6:46 pmHaving trouble with Checkbox and Database. I have an application which records whether someone is attending our event or not. I am using a Checkbox for Attending. The Database field is Attending Boolean.
Should clicking on the Checkbox save to the Boolean field in the database 'True' or 'False'
Or should the database field be string field to kept the Status of the Checkbox "Checked" or not.
How do I link the Checkbox to the Database field to indicate the Attending or not so it shows the correct status?
Help would be appreciated.
Having trouble with Checkbox and Database. I have an application which records whether someone is attending our event or not. I am using a Checkbox for Attending. The Database field is Attending Boolean.
Should clicking on the Checkbox save to the Boolean field in the database 'True' or 'False'
Or should the database field be string field to kept the Status of the Checkbox "Checked" or not.
How do I link the Checkbox to the Database field to indicate the Attending or not so it shows the correct status?
Help would be appreciated.
Quote from Gaev on September 5, 2021, 8:38 pm@cssystems
You will see on this help file page ... https://winhelp.visualneo.com/CheckBoxTool.html ... that the state of the Checkbox is stored in a variable of the same name (unless you chose to change it) ... this variable will contain the text/string of "Checked" when the user has checked the box.
Should clicking on the Checkbox save to the Boolean field in the database 'True' or 'False'
Or should the database field be string field to kept the Status of the Checkbox "Checked" or not.While you can use a Boolean (True/False) field to store the information on the database, it is probably better to assign a Char field (length of 7 will hold the word Checked) ... and then store the content of the variable associated with the Checkbox object AS IS ... same when reading the record (later on) and populating the Checkbox (in case you need to edit/change this record).
You will see on this help file page ... https://winhelp.visualneo.com/CheckBoxTool.html ... that the state of the Checkbox is stored in a variable of the same name (unless you chose to change it) ... this variable will contain the text/string of "Checked" when the user has checked the box.
Should clicking on the Checkbox save to the Boolean field in the database 'True' or 'False'
Or should the database field be string field to kept the Status of the Checkbox "Checked" or not.
While you can use a Boolean (True/False) field to store the information on the database, it is probably better to assign a Char field (length of 7 will hold the word Checked) ... and then store the content of the variable associated with the Checkbox object AS IS ... same when reading the record (later on) and populating the Checkbox (in case you need to edit/change this record).
Quote from PaulJonestindall on September 7, 2021, 10:10 am@cssystems
If you're using an Access DB, an MDB file, in Access the CheckBox boolean field will be "-1" if checked and "0" if unchecked. When read by DBPro the field variable will return as "Checked" or "False". I know it seems a bit confusing. I don't know how other DB types handle the boolean but it's probably safe to just check if the variable is "Checked".
If "[party.guestlist.attend]" "=" "Checked"
SetVar "[Attending]" "I'll be there with bells on."
Else
SetVar "[Attending]" "Sorry. I'm washing my hair."
EndIfYou might just run your action code in debug mode and see what your variables return and write your code accordingly.
If you're using an Access DB, an MDB file, in Access the CheckBox boolean field will be "-1" if checked and "0" if unchecked. When read by DBPro the field variable will return as "Checked" or "False". I know it seems a bit confusing. I don't know how other DB types handle the boolean but it's probably safe to just check if the variable is "Checked".
If "[party.guestlist.attend]" "=" "Checked"
SetVar "[Attending]" "I'll be there with bells on."
Else
SetVar "[Attending]" "Sorry. I'm washing my hair."
EndIf
You might just run your action code in debug mode and see what your variables return and write your code accordingly.