473,666 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to make a bound checkbox remain checked for new records

5 New Member
I'm trying to do something I thought would be simple enough even for me, but I'm stuck. I have a checkbox on a form bound to a yes/no column in a table.

I want the user to be able to check the box and have it remained checked as they enter new records, thus saving the tables field as YES for as many records as they wish until they uncheck it. Then when they uncheck it, have it remain unchecked as they create new records, etc...

Eventually I'm going to create either a toggle or command button that does the checking of teh check box for them and probably hide the Check Box control, but that part I can figure out. It's getting it to stay checked or unchecked for each new record until toggled back that's throwing me.
I feel really dumb even asking this question but I'm stumped. I know that an unbound checkbox kind of does what I want, but then how to get it to store the Yes/No answers where I want it to I don't know how to do either. Uhgg I'm so confused. Thanks in advance for your help.
Mar 14 '11 #1
8 4081
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
Hi and welcome to Bytes

What you want to do is "simply" modify the default value of your checkbox. Add code to the checkbox' Click Event as such:
Expand|Select|Wrap|Line Numbers
  1. Private Sub chkBox_Click()
  2.     Me.chkBox.DefaultValue = Me.chkBox
  3. End Sub
Mar 14 '11 #2
Rabbit
12,516 Recognized Expert Moderator MVP
In the after update event of the checkbox, you'll want to change the default of the checkbox to what it was just changed to.
Mar 14 '11 #3
NeoPa
32,568 Recognized Expert Moderator MVP
This is a bit complex to follow, so I'll lay it out as clearly as I can. First let me say that the other two answers are clearly correct.

You need to start off with two checkboxes on your form. One for the bound field of your table. The other to indicate, and allow the operator to change, the value that should be treated as the default going forwards. Let's call them chkBound and chkUnbound for now.

You explanation isn't entirely clear, so I'll assume you want to start a session with the default set to True. If this is not the case then please disabuse me. This value (True) should be set as the .DefaultValue in the design of the form for both controls.

Whenever the operator changes the value in chkUnbound, the .DefaultValue of chkBound should be changed to reflect the new value (of chkUnbound).
Mar 14 '11 #4
Jim Monica
5 New Member
Thank You everyone for your replies. I went with the first method as that seemed to be the simplest and with my limited brain power and knowledge, simple is good. Now my next task is to make a toggle button (I think) that allows the user to toggle the checkbox on/off or checked and unchecked. I know I could just use the checkbox for that, but my boss is insisting it be a button because it's also going to change the background of the form or give some other indicator to let the user know they are in the mode where the check box is checked. The ChkBox is there so that when the user is entering inventory items, the items are flagged as consignment items (if checked) and they will usually enter these items in a row in groups of about 50-100 which is why I needed the checkbox to stay checked until they uncheck it. Now I need to somehow Clearly tell the user they are in "Consignmen t Mode" thus telling them that all of the items they are entering are being flagged as consignment until they hit the button again and go back to "normal" mode. So that's what you guys (or gals) just helped me with and I REALLY appreciate it. Now to google Toggle button. Thank You again everyone!
Mar 15 '11 #5
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
I have tried to keep this simple:
Basicly I have added a togglebutton togBtn and when its clicked it changes the caption on the button, and colours the detail area of the form. (Just for example, you could do other things).

The only "complicate d" part is that I have added to the forms Current Event to only colour those records that are new (I.e. dont show the red consignment mode for existing records)

Here is the code: (If this is a continues form you are using, then note that colouring the detail area is not the best approach to use, since it will colour all the records detail area, but you could colour the header area instead.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     If Me.NewRecord And Me.chBox.DefaultValue Then
  3.         Me.Detail.BackColor = vbRed
  4.     Else
  5.         Me.Detail.BackColor = vbCyan
  6.     End If
  7. End Sub
  8.  
  9. Private Sub togBtn_Click()
  10.     'Change default value
  11.         Me.chBox.DefaultValue = Not Me.chBox.DefaultValue
  12.  
  13.     'Change caption on toggle button
  14.         If Me.chBox.DefaultValue Then
  15.             Me.togBtn.Caption = "Consignment Mode"
  16.             Else
  17.             Me.togBtn.Caption = "Other Mode"
  18.         End If
  19.  
  20.     'If this is a newrecord and default is true, color it
  21.         If Me.NewRecord And Me.chBox.DefaultValue Then
  22.             Me.Detail.BackColor = vbRed
  23.         Else
  24.             Me.Detail.BackColor = vbCyan
  25.         End If
  26. End Sub
Mar 15 '11 #6
Jim Monica
5 New Member
Thanks very much for your fast reply. I feel kind of guilty because your basically writing this program for me with these tips. I really do appreicate your help. You've saved me so much time! Thanks again!
Mar 15 '11 #7
NeoPa
32,568 Recognized Expert Moderator MVP
Your boss clearly has experience with interfaces and how important that is when designing software.

Smiley's solution includes everything I brought up, except what you put on the form is down to you of course, including the slight change to the spec from the original question (Different events required for CommandButton than CheckBox controls). He's even warned you about the continuous forms issue. As they say "You're good to go!"
Mar 15 '11 #8
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
Your welcome.

Don't spend time on being guilty, spend the time on understanding WHY/HOW the code works. Too many people just copy code from this site(or others), without spending a single minute on understanding WHY/HOW it works.
Mar 15 '11 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
366
by: Alex | last post by:
I found some good information On "Including a Data Bound CheckBox in an Editable DataGrid... " at this site http://www.dedicatedsolutions.co.uk/DesktopDefault.aspx?tabid=62 It is worth the click
2
3274
by: Zvonko Bi¹kup | last post by:
Hi! I have 5 checkboxes with the same name: <input type="checkbox" name="check" value="XYZ" /> <input type="checkbox" name="check" value="ZXY" /> <input type="checkbox" name="check" value="MHG" /> <input type="checkbox" name="check" value="IOJ" /> <input type="checkbox" name="check" value="BGT" /> How to check if at least one is checked?
3
3304
by: paoparaopao | last post by:
Hi, I am creating a new screen in a GUI. Can someone help me how can I make a checkbox look like it is enabled? For example, I use this code EUAMIndCheckBox.setEditable(false); and the checkbox appears to be blur. I know the reason is that to inform the user that it is not editable. But I want it to look like it is enabled but it is not. Hope someone can help me about this. Thanks.
4
13677
by: sara | last post by:
Hi - I've looked at many posts, and cannot find the answer on this specific problem. I have several fields on a table, which I've defined as "Text", 3 characters, Format Yes/No (I picked up the Text and Format Yes/No from a Posting). I have a form with a label and a check box for each item and the user checks off the ones s/he wants to be "Yes".
2
2775
by: JLC | last post by:
Hi, I am creating a page in asp.net that has a checkbox and a textbox. When the checkbox is checked I want the textbox to become active and show text. If the checkbox is unchecked, I would like the text box to become disabled and show no text. Is this possible to do via javascript? I would like to handle it all client side. Thanks, JLC
2
5417
by: dkultasev | last post by:
Hello, I have small script which generates some listboxes. Their names are listXX (list01, list02, list03....). How to check if there are checked or not ? If I have 1 listbox and have it's name I do $_POST. But what to do in that situation ? Sincerely, Dmitrij
5
1361
nev
by: nev | last post by:
i use mysql. i have a bound checkbox which returns 'checked' or 'unchecked' values into my database. what i want to achieve is for it to inject 1 or 0 into my database. how do?
3
12237
by: Jill1975 | last post by:
I work with a large group of people who enter tons of records each day. To seach for a specific record takes a long time. To help manage this, I have duplicated the form. One form will hold all records (open and closed) and the other form would only show the open records. In the open records form, I would like to hide a record once a checkbox is checked which indicates it is a closed record. The form was built with multiple tables. ...
3
3815
by: SoNew | last post by:
I am trying to add a checkbox to a form and am having a rather basic problem. As you will quickly tell I am not an access person, but my boss seems to think so :) Anyhow, I needed to add a field but couldn't add it to the original table as it is linked. So I created a new table just for the sake of tracking the data. (called Mentor). I created a primary key auto number (ingMentorID), the checkbox info (blnMentor) and (ReadingCoachID) which...
13
17283
wordbrew
by: wordbrew | last post by:
Hopefully this has a simple solution either by VBA or in the properties box. I have a report in Access called JeppList in which the field is pulling the data from my form entitled OrderForm from a checkbox (also called ). The report is working fine listing "yes" if the checkbox is checked, and "no" if it is left blank. However, this list goes to an offsite vendor. Instead of a long list of yes's and no's where they have to comb...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.