473,734 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help on If statment function using a range to input a value in to a text box

Hello,

This is my second post to the any usernet group and the first one was
posted to the wrong one.
I am currently working on creating an order form for sales associates
at my work to be used at conventions. I have a main form with two
subforms. On the main form, there is a text box that displays the sum
of total orders entered in the subform, [SUBTOTAL]. I'm trying to
create another text box on the main form, [GIFTS] that looks at the
subtotal text box and
depending on the value, updates the filed with appropriate value.

I have set the control source of the Gifts text box to be the same as
in the Subtotal text box. Which is =[Orders Subform].Form!
OrderSubtotal.

I have entered the following code in the "event after update" of the
GIFTS tex box.

Private Sub Gifts_AfterUpda te()
If [Subtotal] >= 0 And [Subtotal] <= 2499 Then
Me.gifts = 0
ElseIf [Subtotal] >= 2500 And [Subtotal] <= 4999 Then
Me.gifts = 250
ElseIf [Subtotal] >= 5000 Then
Me.gifts = 600
End If

End Sub

The reply I got from original post of this message said that I need to
refer to the value propety of the textbox and not the textbox itself.
I did that by changing the above code to all instances of [subtotal]
in the above code with [subtotal].value

Please help me,

Thank you,

Victoria

Mar 1 '07 #1
5 3231
On Mar 1, 2:20 pm, vsteshe...@dent sply.com wrote:
Hello,

This is my second post to the any usernet group and the first one was
posted to the wrong one.
I am currently working on creating an order form for sales associates
at my work to be used at conventions. I have a main form with two
subforms. On the main form, there is a text box that displays the sum
of total orders entered in the subform, [SUBTOTAL]. I'm trying to
create another text box on the main form, [GIFTS] that looks at the
subtotal text box and
depending on the value, updates the filed with appropriate value.

I have set the control source of the Gifts text box to be the same as
in the Subtotal text box. Which is =[Orders Subform].Form!
OrderSubtotal.

I have entered the following code in the "event after update" of the
GIFTS tex box.

Private Sub Gifts_AfterUpda te()
If [Subtotal] >= 0 And [Subtotal] <= 2499 Then
Me.gifts = 0
ElseIf [Subtotal] >= 2500 And [Subtotal] <= 4999 Then
Me.gifts = 250
ElseIf [Subtotal] >= 5000 Then
Me.gifts = 600
End If

End Sub

The reply I got from original post of this message said that I need to
refer to the value propety of the textbox and not the textbox itself.
I did that by changing the above code to all instances of [subtotal]
in the above code with [subtotal].value

Please help me,

Thank you,

Victoria

I'll assume you have the value in [SubTotal] coming in correctly.
The reply you previously got is not entirely correct in that the Value
property is the default of a textbox - so when you refer to it like
Variable = [Subtotal] you are actually refering to it's value. The
first thing I see you doing wrong in your code, is that you must
include the form reference when refering to the control, I use either
Forms("FormName ") or Me depending on where the code is. In your case
it should be Me!Subtotal.

Second you may find it more manageable to use a Select Case
statement...

Select Case Me!Subtotal
Case 0 To 2499 '(Or <=2499 to account for negatives)
Me!Gifts = 0
Case 2500 To 4999
Me!Gifts = 250
Case >=5000
Me!Gifts = 600
Case Else
Me!Gifts=0
End If

Mar 1 '07 #2
On Mar 1, 3:16 pm, "storrboy" <storr...@sympa tico.cawrote:
On Mar 1, 2:20 pm, vsteshe...@dent sply.com wrote:


Hello,
This is my second post to the any usernet group and the first one was
posted to the wrong one.
I am currently working on creating an order form for sales associates
at my work to be used at conventions. I have a main form with two
subforms. On the main form, there is a text box that displays the sum
of total orders entered in the subform, [SUBTOTAL]. I'm trying to
create another text box on the main form, [GIFTS] that looks at the
subtotal text box and
depending on the value, updates the filed with appropriate value.
I have set the control source of the Gifts text box to be the same as
in the Subtotal text box. Which is =[Orders Subform].Form!
OrderSubtotal.
I have entered the following code in the "event after update" of the
GIFTS tex box.
Private Sub Gifts_AfterUpda te()
If [Subtotal] >= 0 And [Subtotal] <= 2499 Then
Me.gifts = 0
ElseIf [Subtotal] >= 2500 And [Subtotal] <= 4999 Then
Me.gifts = 250
ElseIf [Subtotal] >= 5000 Then
Me.gifts = 600
End If
End Sub
The reply I got from original post of this message said that I need to
refer to the value propety of the textbox and not the textbox itself.
I did that by changing the above code to all instances of [subtotal]
in the above code with [subtotal].value
Please help me,
Thank you,
Victoria

I'll assume you have the value in [SubTotal] coming in correctly.
The reply you previously got is not entirely correct in that the Value
property is the default of a textbox - so when you refer to it like
Variable = [Subtotal] you are actually refering to it's value. The
first thing I see you doing wrong in your code, is that you must
include the form reference when refering to the control, I use either
Forms("FormName ") or Me depending on where the code is. In your case
it should be Me!Subtotal.

Second you may find it more manageable to use a Select Case
statement...

Select Case Me!Subtotal
Case 0 To 2499 '(Or <=2499 to account for negatives)
Me!Gifts = 0
Case 2500 To 4999
Me!Gifts = 250
Case >=5000
Me!Gifts = 600
Case Else
Me!Gifts=0
End If- Hide quoted text -

- Show quoted text -
Hello and thank you for your response.

I have first tried editing the code by replacing subtotal with Me!
[subtotal] and then by replacing the if statment with the select case
statment that you wrote with the same results. When I go back to the
form, all I see in the gifts text box is the amount that appears in
the subtotal box.

Private Sub gifts_AfterUpda te()
Select Case Me.Subtotal
Case 0 To 2499 '(Or <=2499 to account for negatives)
Me!Gifts = 0
Case 2500 To 4999
Me!Gifts = 250
Case Is >= 5000
Me!Gifts = 600
Case Else
Me!Gifts = 0

End Select
End Sub

Any ideas?

Mar 2 '07 #3
On Mar 1, 9:51 pm, "Victoria" <vsteshe...@den tsply.comwrote:
On Mar 1, 3:16 pm, "storrboy" <storr...@sympa tico.cawrote:
On Mar 1, 2:20 pm, vsteshe...@dent sply.com wrote:
Hello,
This is my second post to the any usernet group and the first one was
posted to the wrong one.
I am currently working on creating an order form for sales associates
at my work to be used at conventions. I have a main form with two
subforms. On the main form, there is a text box that displays the sum
of total orders entered in the subform, [SUBTOTAL]. I'm trying to
create another text box on the main form, [GIFTS] that looks at the
subtotal text box and
depending on the value, updates the filed with appropriate value.
I have set the control source of the Gifts text box to be the same as
in the Subtotal text box. Which is =[Orders Subform].Form!
OrderSubtotal.
I have entered the following code in the "event after update" of the
GIFTS tex box.
Private Sub Gifts_AfterUpda te()
If [Subtotal] >= 0 And [Subtotal] <= 2499 Then
Me.gifts = 0
ElseIf [Subtotal] >= 2500 And [Subtotal] <= 4999 Then
Me.gifts = 250
ElseIf [Subtotal] >= 5000 Then
Me.gifts = 600
End If
End Sub
The reply I got from original post of this message said that I need to
refer to the value propety of the textbox and not the textbox itself.
I did that by changing the above code to all instances of [subtotal]
in the above code with [subtotal].value
Please help me,
Thank you,
Victoria
I'll assume you have the value in [SubTotal] coming in correctly.
The reply you previously got is not entirely correct in that the Value
property is the default of a textbox - so when you refer to it like
Variable = [Subtotal] you are actually refering to it's value. The
first thing I see you doing wrong in your code, is that you must
include the form reference when refering to the control, I use either
Forms("FormName ") or Me depending on where the code is. In your case
it should be Me!Subtotal.
Second you may find it more manageable to use a Select Case
statement...
Select Case Me!Subtotal
Case 0 To 2499 '(Or <=2499 to account for negatives)
Me!Gifts = 0
Case 2500 To 4999
Me!Gifts = 250
Case >=5000
Me!Gifts = 600
Case Else
Me!Gifts=0
End If- Hide quoted text -
- Show quoted text -

Hello and thank you for your response.

I have first tried editing the code by replacing subtotal with Me!
[subtotal] and then by replacing the if statment with the select case
statment that you wrote with the same results. When I go back to the
form, all I see in the gifts text box is the amount that appears in
the subtotal box.

Private Sub gifts_AfterUpda te()
Select Case Me.Subtotal
Case 0 To 2499 '(Or <=2499 to account for negatives)
Me!Gifts = 0
Case 2500 To 4999
Me!Gifts = 250
Case Is >= 5000
Me!Gifts = 600
Case Else
Me!Gifts = 0

End Select
End Sub

Any ideas?

Are you aware that the AfterUpdate event only occurs when the user
changes the textbox's value. If your intention is to update the Gifts
textbox when the subform changes then this approach does not work. I
think you may need to remove the ControlSource from Gifts and use the
AfterUpdate event of the subform to change it's value. Otherwise I may
not quite understand what you are trying to do.

Private Sub Orders_ SubformActualNa me_AfterUpdate( )
Select Case Me!OrderSubtota l
Case 0 To 2499 '(Or <=2499 to account for negatives)
Me.Parent!Gifts = 0
Case 2500 To 4999
Me.Parent!Gifts = 250
Case Is >= 5000
Me.Parent!Gifts = 600
Case Else
Me.Parent!Gifts = 0
End Select
End Sub

Mar 2 '07 #4
On Mar 1, 11:13 pm, "storrboy" <storr...@sympa tico.cawrote:
On Mar 1, 9:51 pm, "Victoria" <vsteshe...@den tsply.comwrote:


On Mar 1, 3:16 pm, "storrboy" <storr...@sympa tico.cawrote:
On Mar 1, 2:20 pm, vsteshe...@dent sply.com wrote:
Hello,
This is my second post to the any usernet group and the first one was
posted to the wrong one.
I am currently working on creating an order form for sales associates
at my work to be used at conventions. I have a main form with two
subforms. On the main form, there is a text box that displays the sum
of total orders entered in the subform, [SUBTOTAL]. I'm trying to
create another text box on the main form, [GIFTS] that looks at the
subtotal text box and
depending on the value, updates the filed with appropriate value.
I have set the control source of the Gifts text box to be the same as
in the Subtotal text box. Which is =[Orders Subform].Form!
OrderSubtotal.
I have entered the following code in the "event after update" of the
GIFTS tex box.
Private Sub Gifts_AfterUpda te()
If [Subtotal] >= 0 And [Subtotal] <= 2499 Then
Me.gifts = 0
ElseIf [Subtotal] >= 2500 And [Subtotal] <= 4999 Then
Me.gifts = 250
ElseIf [Subtotal] >= 5000 Then
Me.gifts = 600
End If
End Sub
The reply I got from original post of this message said that I need to
refer to the value propety of the textbox and not the textbox itself.
I did that by changing the above code to all instances of [subtotal]
in the above code with [subtotal].value
Please help me,
Thank you,
Victoria
I'll assume you have the value in [SubTotal] coming in correctly.
The reply you previously got is not entirely correct in that the Value
property is the default of a textbox - so when you refer to it like
Variable = [Subtotal] you are actually refering to it's value. The
first thing I see you doing wrong in your code, is that you must
include the form reference when refering to the control, I use either
Forms("FormName ") or Me depending on where the code is. In your case
it should be Me!Subtotal.
Second you may find it more manageable to use a Select Case
statement...
Select Case Me!Subtotal
Case 0 To 2499 '(Or <=2499 to account for negatives)
Me!Gifts = 0
Case 2500 To 4999
Me!Gifts = 250
Case >=5000
Me!Gifts = 600
Case Else
Me!Gifts=0
End If- Hide quoted text -
- Show quoted text -
Hello and thank you for your response.
I have first tried editing the code by replacing subtotal with Me!
[subtotal] and then by replacing the if statment with the select case
statment that you wrote with the same results. When I go back to the
form, all I see in the gifts text box is the amount that appears in
the subtotal box.
Private Sub gifts_AfterUpda te()
Select Case Me.Subtotal
Case 0 To 2499 '(Or <=2499 to account for negatives)
Me!Gifts = 0
Case 2500 To 4999
Me!Gifts = 250
Case Is >= 5000
Me!Gifts = 600
Case Else
Me!Gifts = 0
End Select
End Sub
Any ideas?

Are you aware that the AfterUpdate event only occurs when the user
changes the textbox's value. If your intention is to update the Gifts
textbox when the subform changes then this approach does not work. I
think you may need to remove the ControlSource from Gifts and use the
AfterUpdate event of the subform to change it's value. Otherwise I may
not quite understand what you are trying to do.

Private Sub Orders_ SubformActualNa me_AfterUpdate( )
Select Case Me!OrderSubtota l
Case 0 To 2499 '(Or <=2499 to account for negatives)
Me.Parent!Gifts = 0
Case 2500 To 4999
Me.Parent!Gifts = 250
Case Is >= 5000
Me.Parent!Gifts = 600
Case Else
Me.Parent!Gifts = 0
End Select
End Sub- Hide quoted text -

- Show quoted text -
I have tried the code and it is still not working. Below is what I
would like to happen.
1. user opens main order form which also has a product subform
2. user enters customer information in the main form and product
information in the subform
The order information gets recorded in the orders table and product
information in orders detail table
3. there is a [OrderSubtotal] in the footer of the product subform
that gets updated with every additional product entered in the
subform. This subtotal is also displayed on the main form.
4.** I would like to add a field in the main form that looks up the
value in [OrderSubtotal] and based on a predefined array mentioned
earlier displays 0, 250 or 600. This number will also be stored in
the main orders table.
This forth step is what I'm trying to create. I think that perhaps
I'm not referencing correct fields.

This is the list of names involved:
Main table is called "Orders"
A field to which I want to append the calculated field value is called
"Gifts"
Main form is called "Orders'' and it is based on query called
OrdersQry that uses Orders table.
Subform is called "OrdersSubf orm"

Looking forward to your response.

Mar 2 '07 #5
>
I have tried the code and it is still not working.
Is there an error message or something? Still just showing the
Subtotal box? I can't see what's wrong with it if you replaced the
control names accordingly. I may have to try and re-create something
small to figure it out.

Mar 3 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2975
by: Allens Mail | last post by:
Help, Due Mon I cant find the error. Keeps saying illegal token } have gone though code and balance all French braces and parenthesis. Please help going crazy. Code below Thanks Allen //************************************************************************** *******
9
2170
by: Max | last post by:
I'm new with Javascript and can't seem to figure out what I'm doing wrong here as I'm not able to pass a simple variable to a function. In the head of doc I have: <script type="text/javascript"> function radioenable(value) { document.forms.search.elements.value.disabled=false;
8
5478
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
11
2413
by: Mannequin* | last post by:
Hi all, I'm working on a quick program to bring the Bible into memory from a text file. Anyway, I have three questions to ask. First, is my implementation of malloc () correct in the program to follow? Second, have I correctly passed the structure's pointer to the functions in this program?
1
3716
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am attach this script files and inq files. I cant understand this error. Please suggest me. You can talk with my yahoo id b_sahoo1@yahoo.com. Now i am online. Plz....Plz..Plz...
1
1747
by: darwin2kx | last post by:
I have a problem that I've been tracking down for a while now. I'm working on a script that dynamically adds blocks for data entry to a page. This script works on one page but not another. For some unknown reason, it seems to be stripping out tags. (And yes, I know the code looks a little messy. It's dynamically created by PHP, and I have to tidy it up a bit still.) What seems to happen is when a link is clicked to add an input, it appears to...
2
3968
by: Chris Smith | last post by:
Howdy, I'm a college student and for one of we are writing programs to numerically compute the parameters of antenna arrays. I decided to use Python to code up my programs. Up to now I haven't had a problem, however we have a problem set where we are creating a large matrix and finding it's inverse to solve the problem. To invert the matrix I've tried using numpy.numarray.linear_algebra.inverse and...
0
5573
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
1
4714
by: lolly | last post by:
hi i recently used a virtual keyboard from www.codeproject.com/jscript/jvk.asp. However this part of the code function keyb_callback(ch) { var text = document.getElementById("textfield"), val = text.value; switch(ch) { case "BackSpace":
0
8946
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
8776
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,...
1
9236
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
8186
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...
1
6735
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 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...
0
6031
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
4550
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3261
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
2724
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.