473,495 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

If Checkbox 1 - True How do I make Check 2 = True

22 New Member
Two check boxes on the same form. I need to make check box 2 = TRUE if Check one is clicked (and so made TRUE)

The following code does not work

Private Sub AirSparging_AfterUpdate()
If Me.AirSparging = True Then Me.Compressor = True
Else: Me.Compressor = False

End Sub

Clearly I am getting something wrong. Can anyone help?

Thank you
Mar 12 '08 #1
7 2782
lee123
556 Contributor
the code your looking for is this:

Expand|Select|Wrap|Line Numbers
  1.  Private Sub AirSparging_AfterUpdate()
  2.  
  3. If  AirSparging.value = True Then 
  4.         Compressor.value = True
  5. Else:
  6.        Compressor.value = False
  7. End If
  8.  
  9. End Sub
  10.  
you could try this, when you are dealing with these checkboxes you need to put the value of it in the code.

lee123
Mar 12 '08 #2
lee123
556 Contributor
oops i forgot the code brackets who which ever moderator see this i can't seem to be patient enought to get that, i know it easy to do but my hands are faster than my mind and eyes. sorry for that but if i could change it i would but i don't know how to and probably can't.

lee123
Mar 12 '08 #3
missinglinq
3,532 Recognized Expert Specialist
Hulm1, Your code was almost correct. This line

If Me.AirSparging = True Then Me.Compressor = True

by itself would be correct. You can place an If...Then statement on a single line, and if you do you don't need an End If statement to match. But when you have an If...Then statement on a single line, you cannot have an Else statement as well. To add the Else statement you have to use the standard If...Then construct along with the End If statement. So your code then becomes

Expand|Select|Wrap|Line Numbers
  1. If Me.AirSparging = True Then
  2.   Me.Compressor = True
  3. Else
  4.   Me.Compressor = False
  5. End If
  6.  
which is the same as lee123's code, because his statement

when you are dealing with these checkboxes you need to put the value of it in the code.”

is incorrect. Since .Value is the default property of Checkboxes, comboboxes and textboxes,

Me.Compressor = True


and

Me.Compressor.Value = True

mean the same thing.

Welcome to TheScripts!

Linq ;0)>
Mar 12 '08 #4
Hulm1
22 New Member
Thank you very much indeed both who replied. However!

If Me.AirSparging = True Then Me.Compressor = True

Does not actually work for some reason. It is actually what I did first.

I wonder if it could be due to either of the following:

Either: because there are two other check boxes that would also
make "compressor" True

If Me.TotalFluidsPumps = True Then Me.Compressor = True
If Me.LNAPLSkimmers = True Then Me.Compressor = True

OR: Because the AfterUpdate event for these checkboxes is not the correct place?

Your help greatly appreciate!
Mar 12 '08 #5
missinglinq
3,532 Recognized Expert Specialist
Two things:

Try

If Me.AirSparging = -1 Then Me.Compressor = -1


What version/service pack of Access are you using?

Linq ;0)>
Mar 12 '08 #6
Hulm1
22 New Member
Thank you again.

While going back into the code to change to "-1" as you suggested, I discovered that while the code was in their, the Properties for "AirSparging" did not show an AfterUpdate Event even though the code was actually in the VBA Editor. I therefore selected AfterUpdate event which took me to the code. I then closed the VBA editor and hey presto! it works. I have encountered that one before so I should have spotted it.

One thing though.

You may recall that I have three separate check boxes which control whether or not Compressor = true (4 if you include the Compressor Check box). It sounds strange but the reason this is needed is that we may provide a quote for just a compressor, or we may provide a quote for air sparging (or total fluids pumps etc.) for which a compressor is needed anyway.

If NONE of the check boxes are True then I need Compressor to be False. If any ONE is True I need compressor to remain TRUE. (For reference, I have a subform "EnquiryCompressor_Edit" which is visible (or not) based on the above check boxes as well. So I have the same issue relating to that.)

For reference, I am using the following code to make the subform(s) visible

Me![EnquirySparging_Edit].Form.Visible = Me.AirSparging
Me![EnquiryCompressor_Edit].Form.Visible = Me.AirSparging


Can you help with this? I feel like I am making off with the jewelery here if I get all this help!

Thanks
Mar 12 '08 #7
Hulm1
22 New Member
By the way, Access 2003 SP3

Thank you
Mar 12 '08 #8

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

Similar topics

2
1890
by: Fred | last post by:
Hi, I defined a form consisting of checkboxes like: <form> <input type="checkbox" name=ck id=ck onclick="check(this.form)" <input type="checkbox" name=ck id=ck onclick="check(this.form)" ........
3
1970
by: Jack | last post by:
<i><input type="checkbox" name="chk_Complete" value="TRUE" <%Response.Write l_IsChecked%>"<%if cbool(l_IsChecked) then Response.Write " checked" Else Response.Write " unchecked"%>> The above...
4
7274
by: Steph | last post by:
Hello, Can someone tell me the script to use for having a change on the same page when using checkbox function ? For example, i would to check one condition and display dynamically a button...
17
14095
by: jdph40 | last post by:
Question 1: In Access 97, I have a form (frmVacationWeeks) with a subform (sbfrmPostVacDates). The subform can have up to 33 records and each record has 2 checkboxes, one for approved and one for...
7
3663
by: Tony Williams | last post by:
I have a check box called Loadtxt and when it is ticked I want the value of a control called EmailDatetxt to be today's date. I am using this code in the AfterUpdate event of the checkbox but it...
2
3772
by: Kufre | last post by:
I need anyone that have done this before to help me. I'm creating a form in Access, in the form has two two checkbox, checkbox A is paid, checkbox B is partial_paid. I want the set the checkbox so...
34
3745
by: clinttoris | last post by:
Hello Experts, I have been told to post this in the Javascript forum as I want to do this client side just before my form gets submitted. Once the user clicks the submit button a javascript...
10
5177
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
2
18251
by: AmitKu | last post by:
<script> function CheckChange() { var mycheck = document.getElementById('test'); mycheck.check = true; } </script> <body> <form id="form1" runat="server">
0
2418
by: dotnetrookie | last post by:
Hi This is my 1st post.I have two checkbox columns in gridview binded through item template. The checkboxes are Category and Subcategory. I have actually removed the duplicate values in the...
0
7120
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6991
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...
0
7160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7373
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...
0
5456
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,...
0
4583
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...
0
3088
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...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
286
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.