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

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_AfterUpdate()
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 3198
On Mar 1, 2:20 pm, vsteshe...@dentsply.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_AfterUpdate()
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...@sympatico.cawrote:
On Mar 1, 2:20 pm, vsteshe...@dentsply.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_AfterUpdate()
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_AfterUpdate()
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...@dentsply.comwrote:
On Mar 1, 3:16 pm, "storrboy" <storr...@sympatico.cawrote:
On Mar 1, 2:20 pm, vsteshe...@dentsply.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_AfterUpdate()
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_AfterUpdate()
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_ SubformActualName_AfterUpdate()
Select Case Me!OrderSubtotal
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...@sympatico.cawrote:
On Mar 1, 9:51 pm, "Victoria" <vsteshe...@dentsply.comwrote:


On Mar 1, 3:16 pm, "storrboy" <storr...@sympatico.cawrote:
On Mar 1, 2:20 pm, vsteshe...@dentsply.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_AfterUpdate()
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_AfterUpdate()
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_ SubformActualName_AfterUpdate()
Select Case Me!OrderSubtotal
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 "OrdersSubform"

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
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
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...
8
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 -------------------------------------------------------------------------------- ...
11
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...
1
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...
1
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...
2
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...
0
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...
1
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 =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.