Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
| Search | Today's Posts | Mark Forums Read
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 14th, 2008, 12:02 PM
Authorized User
 
Join Date: May 2008
Location: BELFAST, , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Registering checked checkboxes in a database

Hi There folks,
I have probably an easy question for ya, I am trying to build a database in VB.net with some success however i'm getting really stuck on one issue. I have a list of checkboxes which will be checked whenever a brochure is sent or requested, this works fine until i try to query wither or not the checkboxes has been checked. I keep getting a data type mismatch error. In access i simply set the filter on sent brochure to yes and that gave me the results. I have been reading as much as possible on this and am getting no where i have found some articles that mention that checkboxes get stored in a 1/0 format and tried this to but no success. I need help in coding that if a checkbox is checked on the form 1st it hets stored in the table and second how to build a query to retive wither or not the sent checkbox has been checked.

 
Old May 14th, 2008, 12:11 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Checkboxes work in 1/0, but access works booleans in -1/0. Since the 0 is false in both cases, the best you can do is checkbox.value * -1 always, and you will get the rigth value inserted in the database, and the same when you recover your data.
For the query, you can still use true/false to get your data, or -1/0, whatever you like more...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old May 14th, 2008, 12:41 PM
Authorized User
 
Join Date: May 2008
Location: BELFAST, , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi gbianchi, Thanks mate for responding however i am unsure what you mean, I know my ignorance must astound you when i try the query

SELECT ContactID, OrganisationName, ContactType, Title, Gender, FirstName, LastName, Address1, Address2, Address3, Address4, Address5, Address6,
                      [E-mail], [Phone#], [Mobile#], DateOfBirth, [Interest Area], [Interest Area2], [Interest Area3], [Interest Area4], [Interest Area5], SummerBrochureReq,
                      PTProspectusReq, FTProspectusReq, LeafletReq, PTbrochureReq, PosterA3Req, PosterA4Req, FlierReq, OtherReq, PTProspectusSent,
                      FTProspectusSent, SummerBrochureSent, LeafletSent, PTbrochureSent, PosterA3Sent, PosterA4Sent, FlierSent, OtherSent, OtherCourses, DateSent,
                      [Date()]
FROM [tblStudents&Organisations]
Where SummerBrochureSent=-1

I get no results at all and if i try with 0 i get all the records that are store irrespective of wither or not there checkboxes are checked or no, also true/false yes/no here always throws up the previous message


 
Old May 14th, 2008, 01:05 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

If you get all the records with 0, then you are not storing changes into the database when you check or uncheck the checkboxes...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old May 14th, 2008, 04:44 PM
Authorized User
 
Join Date: May 2008
Location: BELFAST, , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks again friend, of course you are correct its seems that i am making changes that will show when the forms are loaded but not updating the database, Think i need to go back and look over the basics again. But thank you for ur response :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkboxes undefined when not checked MS Access Morn ASP.NET 2.0 Basics 29 February 19th, 2007 04:58 PM
Checkboxes undefined when not checked MS Access Morn Classic ASP Basics 0 February 15th, 2007 05:07 PM
Keep track of checkboxes checked in one CASE stmt markw707 Javascript How-To 0 December 29th, 2006 12:28 PM
Registering a new user hasanali00 BOOK: ASP.NET Website Programming Problem-Design-Solution 4 April 14th, 2005 05:07 AM
Registering DLL's askenkray Classic ASP Components 4 January 27th, 2005 03:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.