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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subtracting records

Status
Not open for further replies.

smiley0q0

Technical User
Feb 27, 2001
356
US
i am fairly new to access, and i know there is an easy answer to this, but i don't know it...
example of my table:

Code Amount
435 1,254.00
475 25,5478.00
378 5,254.00
657 4,785.00

how do it subtract the amount of code 378 from the amount of code 475? or any other amount...
 
What are you doing with this value? Displaying it on a form? Storing it in a table? Is it in a query? Why not just create a global function and pass the values to it.
Mike Rohde
rohdem@marshallengines.com
 
it is in a table and i want to put the difference of the 2 amounts in a report. i was trying to use a qeury, but was having trouble... i don't know much about vb or global functions.
 
Open your database and click on the modules tab. Click 'new' to create a new module. Enter the code:

Public Function difference(num1 as integer, num2 as integer)
difference = num1 - num2
end function


Now save the module (what you save it as doesn't matter)

Now you can call this function from a query, report, form, or another module. The way to call it is

somevalue = difference(4,2)

This example would set the variable somevalue to 2.

You can pass other variables to the function as parameters:

somevalue = difference(me.box1, me.box2)

Hope this helps


Mike Rohde
rohdem@marshallengines.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top