473,396 Members | 1,713 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.

query calculation

Gx
I have this form with the fields:

* Product: (drop down combo box)
with choices - X, Y

* Amount: (currency )

* Balance (currency)

I want to associate product X with the percentage amount of 50 %, Y with 10
%
So by selecting product X from the drop down combo box and then typing an
amount in the Amount field...... the Balance field will then automatically
calculate: amount x 0.50
The problem is the association part from the selection of a product in the
drop down box. How can i do this in a query ?
Nov 12 '05 #1
1 6983
You don't do this kind of thing in a query. Use a form.
Use Datasheet view if you want the form to look like a query.
You can then use the AfterUpdate event procedure of the combo to assign a
value to the balance.

The combo box will have its Row Source property set to the Product table. If
you already have it set up, add a field to the Product table to indicate the
percentage. It will be a Number field, of size Double, and its Format
property set to Percent.

Now set the RowSource of the combo to a query statement that includes the
percentage field. Something like this:
SELECT ProductID, ProductName, AssocPercent FROM tblProduct;

Then set the combo's AfterUpdate proeprty to
[Event Procedure]
Click the build button beside this so Access opens the code window.
Enter the code so it looks like this:

Private Sub ProductID_AfterUpdate()
With ProductID
If Not (IsNull(.Value) Or IsNull(Me.Amount)) Then
If IsNumeric(.Column(2)) Then
Me.Balance = Round(Me.Amount * .Column(2), 2)
End If
End If
End With
End Sub

Note:
The Column property is zero based (i.e. the first column is 0, the 2nd is 1,
....).
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Gx" <sk**@optusnet.com.au> wrote in message
news:3f***********************@news.optusnet.com.a u...
I have this form with the fields:

* Product: (drop down combo box)
with choices - X, Y

* Amount: (currency )

* Balance (currency)

I want to associate product X with the percentage amount of 50 %, Y with 10 %
So by selecting product X from the drop down combo box and then typing an
amount in the Amount field...... the Balance field will then automatically calculate: amount x 0.50
The problem is the association part from the selection of a product in the
drop down box. How can i do this in a query ?

Nov 12 '05 #2

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

Similar topics

1
by: DD | last post by:
I have made a form from a query that calculates -=Total I want to add a field Named this field then recalculates the MarkUp and Discount Fields and Total, I can do some code in the report which...
4
by: d.p. | last post by:
Hi all, I'm using MS Access 2003. Bare with me on this description....here's the situation: Imagine insurance, and working out premiums for different insured properties. The rates for calculating...
0
by: leavandor | last post by:
I am trying to design a query that works with a relationship between a Table and a Query. I am comparing a value in the table with a computed value inside the query. The reason for this is that...
14
by: Crimsonwingz | last post by:
Need to calculate a sum based on a number of factors over a period of years. I can use formula ^x for some of it, but need totals to carry over in the sum and have only been able to do this thus...
3
by: martlaco1 | last post by:
Trying to fix a query that (I thought) had worked once upon a time, and I keep getting a Data Type Mismatch error whenever I enter any criteria for an expression using a Mid function. Without the...
5
by: jonm4102 | last post by:
I'm trying to calculate the median of some numerical data. The data can only be found in a query (henceforth query 1) field I previously made, and I would prefer to calculate the median in a new...
4
by: heckstein | last post by:
I am a novice working in Access 2002 trying to run a query I created. I am receiving the error "scaling of decimal value resulted in data trunction", which I have determined is due to this...
4
by: anniebai | last post by:
I have a query named "Tuition Calculation" saved in the database. In the code, the criteria of the query need to be added/modified and be saved for use of another auto-generate report. Is...
14
klarae99
by: klarae99 | last post by:
Hello, I am working on an Access 2003 Database for inventory control. I am setting up a form (frmProducts) for the viewing and adding of product information. I have several tables that this...
3
by: oopsatwork | last post by:
I'm trying to construct an XPath and it is giving me trouble. I have an XML that contains a "Routine". The routine contains "Steps". The steps have different types. Some types of steps have...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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
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
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...

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.