473,507 Members | 3,112 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

checkbox

1 New Member
hi everybody
i have a form called MATERIAL DETAILS
i have 2 textbox and a checkbox on the form
qty-------bound textbox to a table
qtybalance----unbound textbox .. a calculated textbox getting its value thru dsum
status---checkbox bound to table

i want the checkbox to be true if qty = qtybalance
please help

thanks in advance
krishnanhemanth
Jul 31 '09 #1
5 2875
Delerna
1,134 Recognized Expert Top Contributor
One way to do that is with vba
In the after update event for "qty" (your bound textbox)

Get to the VBA window for that event from the Events tab on the textbox properties window
click afterupdate and then the button with 3 dots in it

Expand|Select|Wrap|Line Numbers
  1. If cstr(qty)=cstr(qtybalance) then checkbox.value=true
  2.  
This is using the names you gave the controls in your question.
I have used cstr() on each textbox in the If statement because
a calculated value in one textbox might not be of the same type as an
entered value in another textbox.
If that is the case then the If will never evaluate to true.
So converting the textbox contents so that they are both strings
guarantees they will be of the same type.
Jul 31 '09 #2
OldBirdman
675 Contributor
1) Don't you need to either have a default value for checkbox or set it in your code?
Expand|Select|Wrap|Line Numbers
  1. If cstr(qty)=cstr(qtybalance) then checkbox.value=true
might be
Expand|Select|Wrap|Line Numbers
  1. If cstr(qty)=cstr(qtybalance) then checkbox.value=true else checkbox.value=false
  2. ---or---
  3. checkbox.value = (cstr(qty)=cstr(qtybalance))
2) Checkbox is a bound control and a calculated value. Isn't this bad database design. Calculated values on a form should not be saved in the table, but recomputed each time. I assume that qtybalance is computed from another table, and that table might change, changing the value computed thru dsum.
3) I don't understand the need for cstr() function. I thought the .value stored by a textbox control was String. Am I correct to think that a bound textbox control displays a formatted string representing the value in the table, and is not a window to the table itself?
Jul 31 '09 #3
ADezii
8,834 Recognized Expert Expert
@OldBirdman
3) I don't understand the need for cstr() function. I thought the .value stored by a textbox control was String.
I do believe that you are correct in this matter, OldBirdman, since the following Expressions will both evaluate to True:
Expand|Select|Wrap|Line Numbers
  1. MsgBox VarType(Me![qty]) = vbString
  2. MsgBox VarType(Me![qtybalance]) = vbString
Jul 31 '09 #4
Delerna
1,134 Recognized Expert Top Contributor
3) I don't understand the need for cstr() function. I thought the .value stored by a textbox control was String.
I thought the same when I tested my code for the post.
My test scenario was this
Expand|Select|Wrap|Line Numbers
  1. Create a form with 2 textboxes and a checkbox
  2. Set the default value for one of the textboxes to 10
  3. enter code ( without cstr() ) 
  4. into the after update event of the other textbox
  5. Run form and enter 10 into the second textbox
  6.  
I set the default value to 10 because
qtybalance----unbound textbox .. a calculated textbox getting its value thru dsum
But the code didnt work, the if statement always evaluated false.

use of Adezii's code shows the values in the 2 textboxes are of a different type.

At least it does in my version of access.
So my conclusion is that the contents of a textbox is not necessarily of type string.
Actually I remember this happening for me in the past in one of my own projects
Therefore my use of CStr()


2) Checkbox is a bound control and a calculated value. Isn't this bad database design. Calculated values on a form should not be saved in the table, but recomputed each time.
Yes it is. A general rule of good database design is "don't save calculated values".
Good or bad, I just answered the question.
To be honest I didn't even notice the statement that the checkbox was bound.
Aug 3 '09 #5
OldBirdman
675 Contributor
At least it does in my version of access.
So my conclusion is that the contents of a textbox is not necessarily of type string.
Actually I remember this happening for me in the past in one of my own projects
Therefore my use of CStr()
You are correct here. I tend to think of Text and String as the same thing. They are, and they're not. "Text" in a table (Access) is a string, but in a "TextBox", it is not. VBA uses "String" and not "Text".
If a textbox is bound to a "Text" field, it is a string. If it is bound to a numeric field, it is not. Data being entered in the temporary area TextBox.Text is a string, and may be converted to other data types during Update.
I will now mentally think of TextBox as DisplayBox (or DBox), which may or may not be text, and may be text while being edited. Thank you for the clarification.
Aug 5 '09 #6

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

Similar topics

4
2031
by: Fabri | last post by:
How can I, on button click, to select ONLY the following 4 checkbox? I would like to do this without a for loop through form.lenght because this is only an example and I have to apply this script...
4
3378
by: feanor | last post by:
I need to select children checkboxes when selecting the parent one. This is my function: function SelectChildrens(checkbox_name){ form = document.forms; Sname = checkbox_name.split("-"); for...
0
2389
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
2
2070
by: bebop | last post by:
I'm using three checkbox web controls in C# .NET and one button, and one labe Is there a way to "group" these individual checkbox web controls If so, do I use a for loop, hashtable, array,...
5
3658
by: DotNetJunkies User | last post by:
1. i want to populate checkboxlist using javascript only at client side ....how can i do this..by populate word i mean that checkboxes should be checked or unchecked on some condition basis.......
2
3024
by: Adam Knight | last post by:
Hi all, I have a datagrid with a checkbox in one column. The checkbox is set to autopostback and calls a method named UpdateMailSubscribers. The first click on the checkbox cause the page to...
2
5505
by: Ceema M via DotNetMonster.com | last post by:
Hello all, I have a nested repeater, which displays categories(parent repeater) and corresponding subcategories(child repeater). Both repeaters have checkboxes. When I check category checkbox...
4
3233
by: Wolfgang Uhr | last post by:
Hello I've the following code Panel pnlData = new System.Windows.Forms.Panel(); CheckBox checkBox = new System.Windows.Forms.CheckBox(); checkBox.AutoSize = true; checkBox.Dock =...
10
5180
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....
0
4078
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
0
7221
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
7313
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
7372
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...
1
7029
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...
0
4702
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
3190
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
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1537
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 ...
1
758
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.