Results 1 to 10 of 10
  1. #1
    thomingo is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    5

    command buttun to subtract 1 from a field value

    S0S.... I nid help on a visual basic If statement in ms access.. I got a form with a field called [copies on hand] so i made a command button and when i click the button, i want the value in the field [copies on hand] to be subtracted by one.....
    The code i hev thats not workin is

    Private Sub Command 25_Click()
    If [copies_on_hand] >0 Then [copies_on_hand] = ([copies_on_hand]-1)


    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Code looks okay. What is happening? I would drop the parentheses, which might be returning a Boolean.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    thomingo is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    5
    nothing is happenin when i click the button..

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Is any code running? The db has to be in a trusted location or you have to explicitly enable code.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    thomingo is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    5
    maybe thats the problem. How do i enable code? Im using access 2007

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Is there a link to click on under the ribbon?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    thomingo is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    5
    yes yes its writen: security warning certain content in the database has been disabled

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    You have to click on that to enable code to run.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    thomingo is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    5
    it worked!! Thank u very much boss!! Yaaay

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Happy to help and welcome to the site!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 12
    Last Post: 03-17-2012, 04:46 AM
  2. Subtract from Previous Row
    By lambo102 in forum Queries
    Replies: 1
    Last Post: 08-06-2011, 09:39 AM
  3. How to do subtract in Query
    By NoOoN in forum Queries
    Replies: 6
    Last Post: 04-07-2011, 01:15 PM
  4. Subtract from inventory
    By NISMOJim in forum Access
    Replies: 5
    Last Post: 01-30-2011, 01:09 PM
  5. Subtract Rows in Query Results
    By Sengenbe in forum Queries
    Replies: 5
    Last Post: 02-08-2010, 06:05 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