This topic is locked

Checkbox value to 'Yes'

2/11/2008 2:25:10 PM
ASPRunnerPro General questions
J
JAT author

Greetings!
I have checkboxes for many fields that are defined as 'text' in my database.
When I check a box, the database fields are populated with -1.
What do I need to do to make my checkboxes enter "Yes" for checked in the database. I'm hoping for a global solution as there are many fields represented by checkboxes.
Thanks!

Sergey Kornilov admin 2/12/2008

Using checkboxes with text field is not a good idea.

Numeric fields works much better for this purpose.
You can use BeforeAdd/BeforeEdit events as a workaround:

if CInt(dict("FieldName"))=0 then

dict("FieldName") = "No"

else

dict("FieldName") = "Yes"

end if


This approach is quite cumbersome if you have several checkbox fields in several tables.

U
uludag 2/13/2008

Hi,

The code above is working great. But I encountered a problem.

My code is:

if CInt(dict("BorrowerId"))=-1 then

dict("OnLoan") = "0"

else

dict("OnLoan") = "-1"

end if


When a book comes back, I delete the name of borrower from list. Then borrowerid becomes empty, and checkbox still seems "onloan".

How can I modify this code in a way that if borrowerid is -1 or empty, then Onloan is 0.

Thanks in advance.

J
Jane 2/13/2008

Hi,
try to use this code:

if CInt(dict("BorrowerId"))=-1 or isnull(dict("BorrowerId")) then

dict("OnLoan") = "0"

else

dict("OnLoan") = "-1"

end if