can this be done?

Mik3

Registered User.
Local time
Today, 09:35
Joined
Jul 10, 2003
Messages
60
I need a value entered from a form to be changed before being written in a table.
The users enters a value in "Quantity Issued" in a form, which is then written in a field "Quantity" in a table.
Now, I need the value entered (say 9) to be written as (-9) in the table. Is it possible to multiply it by (-1) or add a (-) before the number?
Thanks

Mike
 
In the after update event of the text box, make the text box equal to whatever they place in the box * (-1)

Me.field = me.field * (-1)

That should do the trick.

Let me know if you need further assistance,

Vassago
 
Mik3,

Just curious as to why do you need it to be a negative number?

Is it for calculation purposes?
You can handle that in a query or even a report.

Or must your absolutely store it as a negative number in the table?
Vassago's method will work AS LONG as no one tries to be smart and enter a negative number

e.g. User enters -8, Vassago's method will change that to 8
- 8 * -1 = 8

If you only want to change positive entered numbers into negative numbers and leave negative numbers alone you should use

PHP:
If Me.field >= 0 then  
Me.field = me.field * (-1)
end if
 
i need it to be negative so that it'll store items recieved as +ve and items issued as -ve.
i'll try what Vassago said first..i'm a beginner and don't know where to write the code you said.
shall i write this as it is Me.field = me.field * (-1) or shall i change me.field with "Quantity" (that's the name of the field)?
 
Use the code Cosmos posted, he thought of something I didn't. (not enough sleep, leave me be :p

Follow these steps:

1. In the properties of the text box you wish to modify, click the events tab.

2. Choose AfterUpdate and click the _ to the right of the textbox.

3. Place Cosmos's code after the sub declaration and before the "End Sub". Make sure to change the "field" to whatever the name of your text box on the form is.

If you need more help, let us know.

Vassago
 
many thanks for your help guys.
i was going to try a validation rule so that only numbers >=0 will be entered.
i'll try this tomorrow at work and let u know :)
thanks again
 
Are you at any point going to generate a report or perform calculationis in a query like

items recieved - items issued

If you are, then you don't really need to store it as a negative number but just keep it as a positive number and use data validation to only allow for number >= 0.
 
thanks guys..it worked!
i don't have items issued/received - i have Quantity to which items are added or subtracted accordingly.
 

Users who are viewing this thread

Back
Top Bottom