473,386 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Multiple fields options controlling one checkbox

I have a situation where I have a checkbox that is supposed to check if one of two criteria happens.

I can get it to check if one of the criteria is true but I'm having issues having it check if the other is.

So if one of the two cases below is true the chkSizeableUpcharge checkbox should be checked. But what's happening is that it's only checking the box if the txtDoorWidth option triggers it. It's ignoring the height, which I'm guessing is because it checks the width later, but I need it to do it based on either of them, like an Or in between but not sure how to write it. Any ideas or help would be appreciated.

Expand|Select|Wrap|Line Numbers
  1. Select Case frm.TxtDoorHt.Value
  2.  
  3.             Case 78, 84, 90, 96, 102, 108
  4.                 frm.chkSizeableUpcharge.Value = False
  5.             Else
  6.                 frm.chkSizeableUpcharge.Value = True
  7.         End Select
  8.  
  9.         'Only valid door widths - 8, 9, 10, 12, 16, 18
  10.         Select Case frm.TxtDoorWidth.Value
  11.  
  12.             Case 96, 108, 120, 144, 192, 216
  13.                     frm.chkSizeableUpcharge.Value = False
  14.             Case Else
  15.                     frm.chkSizeableUpcharge.Value = True
  16.  
  17.         End Select
Apr 10 '13 #1
8 1237
Rabbit
12,516 Expert Mod 8TB
That's because your else option in your second select is going to override whatever the first select did. What you'll want to do is nest your selects.
Apr 10 '13 #2
Thank you, I understand what you're saying but when I try and nest them the way that I think that would normally work with a If Then Else scenario, it doesn't work, it still will check the box when the height is non-standard if I put height first when I nest it, than it will check the box for the height if it's wrong but not for the width if it's wrong and the height is ok. Same if I swap them, it will do the width but not the height.

I know I'm probably nesting it wrong, so any guidance would be appreciated. I have had to pick up this programming thing on my own, and this program has a ton of code in it.

My attempt based on what I think you said is below.

Expand|Select|Wrap|Line Numbers
  1.  Select Case frm.TxtDoorHt.Value
  2.  
  3.                 Case 78, 84, 90, 96, 102, 108
  4.                         frm.chkSizeableUpcharge.Value = False
  5.  
  6.                     Select Case frm.TxtDoorWidth.Value
  7.                         Case 96, 108, 120, 144, 192, 216
  8.                             frm.chkSizeableUpcharge.Value = False
  9.                     End Select
  10.  
  11.                 Case Else
  12.                     frm.chkSizeableUpcharge.Value = True
  13.  
  14.         End Select
Apr 10 '13 #3
Rabbit
12,516 Expert Mod 8TB
You nested it in the wrong place. It needs to be nested in the the Else.
Apr 10 '13 #4
Thank you for the clarification. I redid it per the below but now both of them have to be true in order to trigger the check box instead of either of them being true.

I changed the code, I hope in the proper way per your instruction to the below. Do you have any further ideas?
Expand|Select|Wrap|Line Numbers
  1. Select Case frm.TxtDoorHt.Value
  2.  
  3.                 Case 78, 84, 90, 96, 102, 108
  4.                         frm.chkSizeableUpcharge.Value = False
  5.  
  6.                 Case Else
  7.                     Select Case frm.TxtDoorWidth.Value
  8.                         Case 96, 108, 120, 144, 192, 216
  9.                             frm.chkSizeableUpcharge.Value = False
  10.                         Case Else
  11.                             frm.chkSizeableUpcharge.Value = True
  12.                     End Select
  13.  
  14.  
  15.         End Select
Apr 10 '13 #5
Rabbit
12,516 Expert Mod 8TB
Sorry, I didn't notice the way you were setting your true/false. You can either flip your conditions or use your first nested example and include an else statement.
Apr 11 '13 #6
vijay6
158 100+
Hey mayala12, in your first code put your second select case statement inside a if statement only if frm.chkSizeableUpcharge.Value is False. i.e., After first select case statement still if chkSizeableUpcharge CheckBox is not checked then execute your second select case statement.
Apr 11 '13 #7
Thank you everyone for your help. I think I have solved this after thinking about it. There is another place in the code where we are doing something similar that I found. I have sort of copied that idea and below is what I came up with and it seems to be working. The feedback was helpful in working through different scenarios and figuring out why it wasn't working etc.

Expand|Select|Wrap|Line Numbers
  1. Select Case frm.TxtDoorHt.Value
  2.  
  3.             Case 78, 84, 90, 96, 102, 108
  4.                 bSizeableHtChk = False
  5.             Case Else
  6.                 bSizeableHtChk = True
  7.  
  8.         End Select
  9.  
  10.         Select Case frm.TxtDoorWidth.Value
  11.             Case 96, 108, 120, 144, 192, 216
  12.                 bSizeableWdthChk = False
  13.             Case Else
  14.                 bSizeableWdthChk = True
  15.         End Select
  16.  
  17.         If bSizeableHtChk = True And bSizeableWdthChk = True Then
  18.             frm.chkSizeableUpcharge.Value = True
  19.         ElseIf bSizeableHtChk = True And bSizeableWdthChk = False Then
  20.             frm.chkSizeableUpcharge.Value = True
  21.         ElseIf bSizeableHtChk = False And bSizeableWdthChk = True Then
  22.             frm.chkSizeableUpcharge.Value = True
  23.         Else
  24.             frm.chkSizeableUpcharge.Value = False
  25.         End If
Apr 11 '13 #8
vijay6
158 100+
Hey mayala12, its sounds good. You found a way to solve your problem by yourself. If you want then still you can optimize your code.

Expand|Select|Wrap|Line Numbers
  1. If bSizeableHtChk = False And bSizeableWdthChk = False Then
  2.             frm.chkSizeableUpcharge.Value = False
  3. Else
  4.             frm.chkSizeableUpcharge.Value = True
  5. End If
Apr 11 '13 #9

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

Similar topics

3
by: Ben Willcox | last post by:
Hi I am having difficulty writing an SQL query to do what I want: I have 1 table with 2 columns, 'id' and 'name': tbl_names: id name -- ---- 1 Bob 2 Jeff 3 Fred
1
by: mark.reichman | last post by:
First off.. Thanks to Grant Wagner for help in a previous thread related to this one. I am at a total loss... I have multiple fields in a form with the same name. Lets call the fields with the...
3
by: tesc | last post by:
I am so aggravated and need any help I can get. I am using Access 2000 and am trying to sort multiple fields in a select query. My query is set up as follows: FIELD 1 FIELD 2 FIELD 3 ...
5
by: JP SIngh | last post by:
Hi All This is a complicated one, not for the faint hearted :) :) :) Please help if you can how to achieve this search. We have a freetext search entry box to allow users to search the...
3
by: mkjets | last post by:
I have worked for hours on trying to find a solution and have not figured it out. I am working in Access 2003. I need to create a query that takes values from 1 table and displays them in...
4
4Him
by: 4Him | last post by:
First off, let me say this is a great site! I've just started working with Access and much of my success is from what I've read here! Background: I have a form, driven off a single table. Goal:...
5
by: Max | last post by:
Is there any way to set a select-multiple type <select multiple="multiple"with multiple selected options in scripting? Any idea about this is appreciative.
2
by: Nathan Sokalski | last post by:
I have a Repeater that uses a DataSource that has multiple fields. When the values of these fields is displayed in the Repeater, there are fields that are used in combination with other fields as...
7
by: john.cole | last post by:
I have searched all the groups I can, and I still haven't been able to come up the solution I need. I have the following problem. In my form named sbfrmSpoolList, I am entering a job, spool and...
482
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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...

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.