Results 1 to 7 of 7
  1. #1
    tsgtnissen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    28

    Question Make Number Negative Automatically

    My Skill Level: SUPER BASIC, but doing my best to learn.

    Question Setup:
    I have attached a picture of an order form I am working on.
    Click image for larger version. 

Name:	order.JPG 
Views:	16 
Size:	33.9 KB 
ID:	19712


    Problem:In the "debit" field I would like to take any number that is input and have access convert it to a negative number.

    My Research:I have looked all over the net and this is what I have found.
    Potential Solution: -1*.'I don't know where to insert this. I have tried over in the properties tab with no luck.


    Potential Solution:-1 * abs(mynumber) 'I don't know where to insert this. I have tried over in the properties tab with no luck.
    Potential Solution:
    Code:
    public function neg(x as number) number
    neg=-1 * abs(x) 
    end function
    
    I dont know where to put this. Should I put in the afterupdate or beforeupdate?

    My crappy fix ATM:
    Click image for larger version. 

Name:	settings.JPG 
Views:	16 
Size:	32.6 KB 
ID:	19713



    Thank you all for your time. I have tried to lay this question out as clear as I can. Please let me know if you need any more information.

    V/R
    TSgtNissen

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    in the AfterUpdate event of the debit field put:

    me.Debit = 0-me.Debit

    that is all you need. You can remove the table field validation rule.

  3. #3
    tsgtnissen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    28
    Click image for larger version. 

Name:	error.JPG 
Views:	11 
Size:	60.7 KB 
ID:	19714
    I get this error when I do that.

    This form is looking is used to add orders to a table "GPC"
    The forms record source is: GPC

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I tested this and it worked. If your control name is not "debit", change "debit" to your control name.
    Code:
    Private Sub debit_AfterUpdate()
        Me.debit = -1 * (Abs(Me.debit))
    End Sub
    As NTC stated, you can remove any table or control level validation rule.

  5. #5
    tsgtnissen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    28
    Thank you so much! That works!

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You're welcome.....

  7. #7
    IslandHydro is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2013
    Location
    Whidbey Island, Washington State, USA
    Posts
    21
    Quote Originally Posted by NTC View Post
    in the AfterUpdate event of the debit field put:

    me.Debit = 0-me.Debit

    that is all you need. You can remove the table field validation rule.
    The OP asked to have the number end up negative regardless of what is input (+ or -) Simply using =0-me.Debit will result in a positive number if the user enters a negative number. =0-Abs(me.Debit) will always return a negative.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Using the (000.00) for a negative number
    By keiath in forum Forms
    Replies: 4
    Last Post: 01-10-2015, 04:43 PM
  2. Replies: 3
    Last Post: 12-07-2013, 01:12 AM
  3. Calculating a negative number
    By bellevue in forum Forms
    Replies: 4
    Last Post: 04-17-2012, 08:18 AM
  4. Replies: 2
    Last Post: 11-22-2011, 11:45 AM
  5. Sum Of Positive Number and Negative Number
    By maysamab in forum Reports
    Replies: 1
    Last Post: 10-20-2008, 04:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums