473,785 Members | 2,714 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

constraining an unbound text box

37 New Member
Hi - I have an unbound text box on a form that calculates a value from a bound text box on the same form. Right now the equation I'm using is
Expand|Select|Wrap|Line Numbers
  1. =Val(NZ([bxpounds]))*0.20
but I would like to have it so if the value that is entered into the bound text box is less than or equal to 100, then that value is put into the unbound text box and if the value is greater than 100 use the equation I already have. I dont have much experience with this type of thing. Any help would be great.
Thanks Sally
Sep 23 '09 #1
9 2229
ajalwaysus
266 Recognized Expert Contributor
Sounds like you need an AfterUpdate on the bxpounds field, something like

Expand|Select|Wrap|Line Numbers
  1. Private Sub bxpounds_AfterUpdate
  2.      If me.bxpounds <= 100 then
  3.          me.[Unbound_textBox].value = me.bxpounds * 0.20
  4.          me.[Unbound_textBox].requery
  5.      Else
  6.          'Execute Your Equation Here
  7.      End If
  8. End Sub
  9.  
-AJ
Sep 23 '09 #2
sillyr
37 New Member
Thank you that worked perfectly
Sep 23 '09 #3
ajalwaysus
266 Recognized Expert Contributor
Glad to help. =)

-AJ
Sep 23 '09 #4
missinglinq
3,532 Recognized Expert Specialist
How does that work for you, Sally? Your original post stated

"if the value is greater than 100 use the equation"

If this is your requirement, the code posted won't work! It uses the equation if the bound control is equal to or less than 100, not greater than 100! If your stated needs are correct, then you need
Expand|Select|Wrap|Line Numbers
  1. Private Sub bxpounds_AfterUpdate
  2.      If Me.bxpounds > 100 then
  3.          Me.[Unbound_textBox].value = Me.bxpounds * 0.20
  4.      Else
  5.          Me.[Unbound_textBox].value = Me.bxpounds
  6.      End If
  7. End Sub
  8.  
And there's no need to requery the textbox after assigning the value.

Linq ;0)>
Sep 23 '09 #5
sillyr
37 New Member
Yes I noticed that mistake and made the correction when I typed the code. Thanks for the advice. Does it matter if I leave in the requery code?
Sep 23 '09 #6
missinglinq
3,532 Recognized Expert Specialist
The requery isn't going to hurt anything, you're just using unnecessary processing time, but with today's powerful processors that's really kind of a moot point.

Linq ;0)>
Sep 23 '09 #7
ajalwaysus
266 Recognized Expert Contributor
In regards to the code I provided, I guess I misunderstood the question, I thought the equation included in the question was different than the..
@sillyr
I thought there was another equation you didn't post. Glad you caught it. Sorry about that.

In regards to the requery, I tend to leave it in my code, because sometimes the field doesn't refresh immediately and people won't see the value. And when that happens a quick response is posted saying "I can't see the data!", so this just helps to have. It's a hit and miss, so you never know when it will happen.

-AJ
Sep 23 '09 #8
missinglinq
3,532 Recognized Expert Specialist
@ajalwaysus
First off, if you're assigning a value to a textbox in the current record, and it doesn't appear immediately, you've got something seriously wrong!

Secondly, there is nothing to requery in an unbound textbox! The data in this textbox is not part of any recordset, which a requery is always run against! Requeries against controls on a form are really only valid for Listboxes and Comboboxes, which can have their own recordsets.

Linq ;0)>
Sep 23 '09 #9
NeoPa
32,577 Recognized Expert Moderator MVP
How about simply using :
Expand|Select|Wrap|Line Numbers
  1. =Val(Nz([bxpounds],0))*IIf(Val(Nz([bxpounds],0))>100,0.20,1)
Sep 23 '09 #10

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

Similar topics

1
19184
by: Stephan | last post by:
Hi, I'm using Visual Studio 2003 (C#) with the integrated Crystal Report software and have the following question: How can I assign a value (string) to an unbound (string) field in Crystal Report at runtime? Example: private void button1_Click(object sender,
2
6164
by: Todd | last post by:
Hello, I'm curious if anyone knows of a way (if one exists) to tell a form (in Access 2002 VBA) to sort on an unbound column of a combo box on the form. Here's what I want to do: A combo box on my form contains a category ID (bound column, not visible, long integer) for the items listed on the form and a description (unbound column, visible, string.) I can "Sort Ascending" and "Sort Descending" on the visible description in the...
2
3893
by: Zlatko Matić | last post by:
Hello. I have the following problem with MS Access/PostgreSQL combination: There is a form in Access that has an unbound text box, used for entering a commentary of a batch of records. There is a DAO Append Query that has a parameter that is passed from the text box using parameter of DAO QueryDef object. I adjusted B7 parameter (Text as LongVarchar) in connection string (ODBC driver) to 1, so that Access links PostgreSQL Text fields as...
2
8264
by: hmiller | last post by:
Hope I make my case clear!!! I have a table with two bound date/time fields. I want to be able to use an IF statement and DateDiff to return a text message in an unbound text box. I want to do this all from the control source of the unbound text box. What I think it should look like is something like this; If(DateDiff("d",,)) > 5, Then Display "On Time"
12
2472
by: MLH | last post by:
Can I somehow set a max length of chars entered into an unbound textbox control?
10
3249
by: Matthew Wells | last post by:
Hello. I've converted a bound Access 2000 form which displays data retrieved from an Access 2000 database to an unbound form. Now my hyperlinks don't work. I'm assuming it's because the form isn't bound anymore. I didn't even have that field's data type as hpyerlink - just test. I did have the form control's "hyperlink" property set to true and it worked fine in bound mode. The fields stores paths to pdf files. How can I make the...
7
2977
by: mukeshhtrivedi | last post by:
Hi I have MS access form which has some text on it in four paragrpahs. Text in first two prargraphs can be changed if I want to and last two paragraphs are not modifiable. When I go to Design View, I see that first two paragraphs shows me as Unbound and text is not displayed. Can anybody guide me how can I change the text from Unbound section as I want to change some text so that when I access Form it should show me with updated text. ...
11
5190
by: jwessner | last post by:
I have a form (Form1) which contains basic Project data and a subform listing the personnel assigned to the Project as a continuous form. Selecting a person on that project and clicking on a command button will open a new form (Form2). Form2 has two subforms. Both are embedded in the main form. (Subform2 is NOT embedded in subform1.) Subform1 displays records as a continuous form based on the Primary ID of the main form and lists the...
1
2251
by: MyWaterloo | last post by:
I have an unbound text box on my main form that is used to show the sum totals in my sub form. I also have a field on my main form that has a control source in a table. This bound field needs to somehow have the total form the unbound text box transferred to it. How do I go about this? I have multiple categories that can be selected through a combo box. So I am sometime just flipping through categories to see what my total is. I could just...
0
9643
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, 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...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10319
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, 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...
1
10087
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8971
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, 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...
0
6737
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();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
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
2
3645
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.