Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formulas in access 1

Status
Not open for further replies.

compudude86

IS-IT--Management
Jun 1, 2006
46
0
0
hi all,
im trying to make a formula to update an item automatically. example

column a column b column c
123 456 789


my formula would be column c = column a - column b / column a
i tried Me((column c)) = Me!((column a)) - ((column b)) / Me!((column a)) without the parentheses.
how would i actually get this to work properly in access?
 

Spaces in field names cause problems in Access unless the name is in brackets, eg [column a].

Putting brackets around the names might fix your problem, avoiding spaces will prevent those problems in the future.

TomCologne
 
First, please post Access questions in the Access forums where you will get more responses.

I'm assuming you're talking about a textbox on a form and not a table. Also, the textbox for the answer is an UNBOUND textbox. You DO NOT save calculations in a table.
On the AfterUpdate event of textboxes for [Lolumn A] and [Column B], you can put:

Me![Column C] = Me![column a] - Me![column b]/Me![Column b]

Or, on the Control source of the textbox for column c, you can put
= Me![column a] - Me![column b]/Me![Column b]

and then put Me![Column B].Requery on the AfterUpdate events.
 
ok, so lets say, i use the expression builder and set column c's control to =[column a]-[column b]/[column a], when i do that, it does not equal a-b/a, if i put it under afterupdate it doesnt work like i expect it to, like when i change column a or b it sets column c to the nearest number to column b.
 
If you need to calculate on your table, have you thought about an append query?

__~o
`\<,
(_)/(_)
MTBChick
The day you stop riding is the day you die.
 
To help us out here, what are your EXACT field names?
And do you want Field1-Field2/Field1 OR (Field1-Field2)/Field1? Remember the Order of Operations?
 
wouldnt that add more rows?

it goes like this:

column a column b column c
1155 3333 .65

any time i change column a or b, i want it to show in column c, so

column a column b column c
1125 3333 .66

but right now its calculating improperly
 
ok,

its finding a gross profit margin, GPM, which is sold price - net price divided by the sold price again

srp netbtl gpm
12.00 5.00 0.58

but when i do it its telling me my gpm is .11
 
jeez, it was order of operations, i was using the expression my boss gave me, he didnt mark it in parenteses, thats what messed me up, so i did it as column c = (column b - column a)/ column b and it worked!!! thank you very much fneily!!!!!
 
yea lol, thanks again, i know ill be back, next step of the project is to take an excel sheet and merge prices from the excel sheet into the databases existing prices, that one looks a little difficult from what ive read elsewhere
 
For ease, can you place the new/updated prices with their corresponding product name on a separate excel sheet? Then, all you would have to do, is to write an Access macro which uses the TransferSpreadsheet action to place the data in a temp table. Then you can have the same macro run Update and/or Append queries to change/add the prices to the Access table holding the data.
 
ok, heres one, anyone know how to make it output a percentage, i.e no decimal point or zero, on my output?
 
Have your division done in an UNBOUND textbox. Then for Format select Percent and for Decimal Places select 0.
 
ok, i figured it out, but now how do i get it to show up in my reports? those still show blanks
 
I don't understand. Do you have an UNBOUND texbox on your report with an expression as Control Source? What is your calculation - .11 or 11% or 11? You must be more specific. And what did you figure out?
 
sry, i didnt realize that i needed to do the same thing in the report design as i do in the form design, so it all works now, thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top