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

Negative and postivive number

Status
Not open for further replies.

libby

ISP
Apr 22, 1999
8
US
I have someone who is using Access like a check register.<br>
He wants to enter all numbers as a positive number, but he wants Access to view the credits as a positive number and the debits as a negative number. Each entry is has an accompanying field that indicates if it is a credit or debit. I would like to write code that tells says something like this. If an entry is designated as a debit make that number negative and if an entry is designated as a credit make that number positive.<br>
<br>
My purpose in this is to have a running sum report and not need to unique columns of numbers to calculate it. Am I approaching this correctly? Is there another way to do this?<br>
<br>
libby@bendcable.com<br>

 
Are your values stored in a table? Form?<br>
<br>
You can always write a function that returns a signed number.
 
Values are stored in a table, but data entry is done in a form.<br>
<br>
How do I write a function that returns a signed number? Though we do not care if the number has a negative sign in front of it. The debits just need to work as a negative in the calculated text boxes of the report, etc.<br>
<br>
Thank you. <br>
libby@bendcable.com
 
Make table where you have two fields: CheckType and Factor<br>
Insert two records: Credit,1 and Debit,-1<br>
Make a query with data table where you link checktypes and make calculated field Factor*Sum and make a report based on this query.<br>
<br>
<br>
Al
 
I have a similar problem in one of my programs. Each month I create a recordset of payments. All the amounts are stored as positive numbers but are identified by a code that designates them as either debits or credits. I created a function that reads every record in the recordset and if the tran code is a debit I simply multiply the debit amount by -1 which coverts the amount to a negative number. Now you can use the values in that recordset to do whatever calculations you want.
 
Let's assume you have a field called 'crdr' for the flag and a field 'amt' for amount.<br>
<br>
You can use the following:<br>
<br>
if crdr = 'c' then <br>
amt=amt 'credits are positives<br>
if crdr = 'd' then<br>
amt = 0 - amt ' debits are negatives<br>
Else<br>
msgbox &quot;Please enter &lt;C&gt;redit or &lt;D&gt;ebit&quot;, &quot;Invalid Entry&quot;<br>
End If<br>
End If<br>
<br>
<br>
Or some derivation from that. But I think you get the point.<br>
<br>
HTH,<br>
<br>
Mapman<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top