473,397 Members | 1,961 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,397 software developers and data experts.

checkbox

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 2874
Delerna
1,134 Expert 1GB
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 512MB
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 Expert 8TB
@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 Expert 1GB
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 512MB
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
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
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
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
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
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
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
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
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
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
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
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
0
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
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
isladogs
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...

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.