I wanted to test for only one True value in a bunch of checkboxes, so I
figured I could just test for a value of exactly -1 after adding the values.
In case 0 below, it worked. But in all other cases, it failed, with a Type
error. Come to find out, sometimes, for no *apparent* reason - "True" is
returned, at other times, -1.
Can someone explain this (seemingly) random behavior, and tell me a way to
force the integer result? CInt(Me!c20) did not work, nor di using the
explicit .Value property.
-------------------------------------------------
Dim i As Integer
Select Case Me!tPages.Value
Case 0
i = Me!c2 + Me!c3
Case 1
i = Me!c20 + Me!c36 + Me!c15 + Me!c25 + Me!c29
End Select
If i <> -1 Then
--------------------------------
--
Darryl Kerkeslager 11 11973
"Darryl Kerkeslager" wrote I wanted to test for only one True value in a bunch of checkboxes, so I figured I could just test for a value of exactly -1 after adding the values.
In case 0 below, it worked. But in all other cases, it failed, with a Type error. Come to find out, sometimes, for no *apparent* reason - "True" is returned, at other times, -1.
Can someone explain this (seemingly) random behavior, and tell me a way to force the integer result? CInt(Me!c20) did not work, nor did using the explicit .Value property.
I don't know why CInt(Me!c20) didn't work for you.
The following is copied directly from the Immediate Window.
? Cint(True)
-1
? Cint(-1)
-1
So, it appears to me that Cint should return -1 whether the Control has a
value of True or a value of -1.
I'd suggest uusing some Debug.Print statements on each of the Controls, and
on CInt applied to each of them to try to debug.
Larry Linson
Microsoft Access MVP
"Larry Linson" <bo*****@localh ost.not> wrote I don't know why CInt(Me!c20) didn't work for you.
The following is copied directly from the Immediate Window.
? Cint(True) -1 ? Cint(-1) -1
So, it appears to me that Cint should return -1 whether the Control has a value of True or a value of -1.
Got lucky! Based on your faith in the correctness of my code, I looked for
another problem. I realized that all the problem areas were calling this
code first:
Private Sub tPages_Change()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then ctl.Value = ctl.DefaultValu e
Next
Set ctl = Nothing
End Sub
So I searched Google for "ctl.DefaultVal ue" and just happened to read one
post where the author used Eval() to enclose the ctl.DefaultValu e.
I assume that Access was randomly (about 15% of the time) interpreting my
default True and False values as strings. Eval() fixed that.
--
Darryl Kerkeslager
Are the checkboxes each bound to a field? If so, what is the data type of
the field each checkbox is bound to? Are they all Yes/No data type fields?
--
Wayne Morgan
MS Access MVP
"Darryl Kerkeslager" <ke*********@co mcast.net> wrote in message
news:Au******** ************@co mcast.com... "Larry Linson" <bo*****@localh ost.not> wrote I don't know why CInt(Me!c20) didn't work for you.
The following is copied directly from the Immediate Window.
? Cint(True) -1 ? Cint(-1) -1
So, it appears to me that Cint should return -1 whether the Control has a value of True or a value of -1.
Got lucky! Based on your faith in the correctness of my code, I looked for another problem. I realized that all the problem areas were calling this code first:
Private Sub tPages_Change() Dim ctl As Control For Each ctl In Me.Controls If ctl.ControlType = acCheckBox Then ctl.Value = ctl.DefaultValu e Next Set ctl = Nothing End Sub
So I searched Google for "ctl.DefaultVal ue" and just happened to read one post where the author used Eval() to enclose the ctl.DefaultValu e.
I assume that Access was randomly (about 15% of the time) interpreting my default True and False values as strings. Eval() fixed that.
-- Darryl Kerkeslager
Maybe I'm misunderstandin g what you're doing, but if you're dealing with a
bunch of true/false cases, it's a boolean, why do you need to use an
integer? Isn't it just an OR?
How about (aircode):
dim bln as boolean
Select Case Me!tPages.Value
Case 0
bln = Me!c2 OR Me!c3
Case 1
bln = Me!c20 OR Me!c36 OR Me!c15 OR Me!c25 OR Me!c29
End Select
if bln=true then
....
And if there's a possibility one of the checkboxes will be null, just
enclose each in
Nz(Me!cX,false)
"Darryl Kerkeslager" <ke*********@co mcast.net> wrote in message
news:Au******** ************@co mcast.com... "Larry Linson" <bo*****@localh ost.not> wrote I don't know why CInt(Me!c20) didn't work for you.
The following is copied directly from the Immediate Window.
? Cint(True) -1 ? Cint(-1) -1
So, it appears to me that Cint should return -1 whether the Control has a value of True or a value of -1.
Got lucky! Based on your faith in the correctness of my code, I looked for another problem. I realized that all the problem areas were calling this code first:
Private Sub tPages_Change() Dim ctl As Control For Each ctl In Me.Controls If ctl.ControlType = acCheckBox Then ctl.Value = ctl.DefaultValu e Next Set ctl = Nothing End Sub
So I searched Google for "ctl.DefaultVal ue" and just happened to read one post where the author used Eval() to enclose the ctl.DefaultValu e.
I assume that Access was randomly (about 15% of the time) interpreting my default True and False values as strings. Eval() fixed that.
-- Darryl Kerkeslager
"Wayne Morgan" <co************ *************** @hotmail.com> wrote Are the checkboxes each bound to a field? If so, what is the data type of the field each checkbox is bound to? Are they all Yes/No data type fields?
No. Unbound.
--
Darryl Kerkeslager
"Bruce Rusk" <br************ ***@stanford.ed oo> wrote Maybe I'm misunderstandin g what you're doing, but if you're dealing with a bunch of true/false cases, it's a boolean, why do you need to use an integer? Isn't it just an OR?
I need to know that ONE and ONLY ONE is checked. Or can't tell me that.
--
Darryl Kerkeslager
If all of the check boxes are unbound and you want to insure that one (and
only one) is checked, then why not use an option box control instead of
multiple check boxes?
Fred Zuckerman
"Darryl Kerkeslager" <ke*********@co mcast.net> wrote in message
news:l_******** ************@co mcast.com... "Bruce Rusk" <br************ ***@stanford.ed oo> wrote Maybe I'm misunderstandin g what you're doing, but if you're dealing with
a bunch of true/false cases, it's a boolean, why do you need to use an integer? Isn't it just an OR?
I need to know that ONE and ONLY ONE is checked. Or can't tell me that. -- Darryl Kerkeslager
In that case, do any of them appear to have a gray center? If so, the value
of those with a gray center is Null. If you don't have the check box set for
Triple State, it will still start off as Null until you check it one time,
then it will alternate between True and False. The way around this is to set
the Default Value of the checkbox to True or False, as desired.
--
Wayne Morgan
MS Access MVP
"Darryl Kerkeslager" <ke*********@co mcast.net> wrote in message
news:U_******** ************@co mcast.com... "Wayne Morgan" <co************ *************** @hotmail.com> wrote Are the checkboxes each bound to a field? If so, what is the data type of the field each checkbox is bound to? Are they all Yes/No data type fields?
No. Unbound. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: cwizard |
last post by:
I'm calling on a function from within this form, and there are values set
but every time it gets called I get slammed with a run time error...
document.frmKitAmount.txtTotalKitValue is null or not an object... the
function is like so:
function calc_total()
{
var x,i,base,margin,total,newmargin,newtotal;
base = document.frmKitAmount.txtTotalKitValue.value;
margin = document.frmKitAmount.margin.value/100;
|
by: WindAndWaves |
last post by:
Hi Folks
I have inhereted a script that I understand reasonably well, I just do not
understand
!/^\d+$/.test(el.value)
what the hell does that mean?
Below is the script (there are really three and they validate a four items
|
by: GS |
last post by:
Hi,
I have following value which I need to check wether it's null or not. Issue is that StartPrice itself can be a null and checking (myItem.StartPrice.Value == null) do not produce true.
How do I check for null in this kind of case. I don't want to check StartPrice for null and then Value for null again as one option. I just want to check Value for null.
Thanks,
Greg
|
by: muthu |
last post by:
Hi freinds,
In my aspx page i have generated some check boxes dynamically
using dhtml.
When i check any check box and submit the form,how can i capture the
value of check box.
How should i identify wich check box is been checked.And the check
boxes are not server controls.They are the ordinary html check
boxes.Can any one help me out
|
by: amraam35 |
last post by:
Here is the problem. I have made a log in script that prompts you to log in with a username and password as the "splash screen" It is an unbounded forum that checks that the username and password are in the employee table, and that they are together, and if it is, it lets you log on. That works just fine. Then i tried to make a form that you can change your password if you please. It has 4 entrys, the user name, password, and then2 of the...
| |
by: leem |
last post by:
Hi
Can some body guide me how to Link the check box value to Text Box. below is the problem .
I've two options in the Check Box method where I've make a Option group for that to select the one value at a time .
1. Check Box1 is named as a "Selling"
2. Check Box2 is named as a "Buying"
I want to calculate the Total Freight from another TextBoxes
|
by: Daz |
last post by:
Hi everyone.
Firstly, I apologise if this i not what you would call a PHP problem. I
get quite confused as to what lives in which realm, so if this
shouldn't be posted here, please suggest where I should post it.
I have created a form, which consists of a list of items, each with a
checkbox. When a checkbox is checked or unchecked, the page should be
refreshed. During the refresh, the data is validated and the MySQL
database is...
|
by: Ecohouse |
last post by:
I have a main form with two subforms. The first subform has the child
link to the main form identity key.
subform1 - Master Field: SK
Child Field: TrainingMasterSK
The second subform has a master-child link to the first subform.
subform2 - Master Field: subTrainingModule.Form!TrainingModuleTopicSK
Child Field: TrainingModuleTopicSK
|
by: Brett Wesoloski |
last post by:
I am having a bit of a problem getting the current value of the checkbox
list.
I have tried using the selected value as I thought that would give me the
current value of the check box but it appears to be giving me the first
value that is selected all the time.
I have also tried to use the selectedItem property but that does the same as
I would expect becuase the property says it get the item with the lowest
value.
|
by: printline |
last post by:
Hello All
I have a script where i need to show the value of a text field in another textfield/field. I have done the same with my radio buttons and select fields like this:
<script type="text/javascript">
function check(layers){
document.forms.answer.value=layers
}
function PrintValues(){
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |