Results 1 to 12 of 12
  1. #1
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36

    Question Access help

    I have a little experencie with Access but still just a newbee. I have a form I put together and within this form I have a filed I wish to have perform an update.

    The field is a text box labeled Qty, next to it is another text box and then beside this text box is two buttons one is labeled ADD and the other is labeled REMOVE.



    What I want to happen is once I have entered a number into the Qty box, I want to be able to enter a number into the second text box and then by pressing either ENTER or REMOVE button have the number in the second text box either added or subtracted from the Qty box.

    Any help would be greatly appreciated

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Me.QtyBox = Me.QtyBox + Me.OtherBox
    ...or...
    Me.QtyBox = Me.QtyBox - Me.OtherBox
    ...using your control names of course.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Qty textbox is bound to field of the form's RecordSource? If Yes then code in the button Click event:

    Me!Qtyfield = Me.tbxQty + Me.otherbox
    Me!Qtyfield = Me.tbxQty - Me.otherbox

    tbxQty is name of the quantity textbox
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36
    Thank you now will this allow me to use the add and remove buttons to preform the action? Also what does the ME. stand for

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Put each line in the Click event of the appropriate button. Be aware, won't prevent user from performing the calculation more than once unless you do somethiing like immediately close the form following the calc action with DoCmd.Close.

    Me. is an alias qualifier for the form/report name. Can be used in code behind the form/report being referenced.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36
    okay that all makes sense to me. Let me ask this then is there a way to code the event to clear the text box once the update is complete so that a person could not reenter the same value?

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Suggest not setting it to null or empty string. Calc with null results in null so you could loose the Qty value and calc with empty string will error.
    You probably should set the Default Value property to 0 so form opens with 0 in the box. Then after the calc simply reset to 0.
    Me.tbxOtherBox = 0

    BTW, updating cumulative data is indication of bad design. A principle of relational database is 'enter raw data, do calcs in reports', including summary (cumulative) calcs.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36
    Thank you very much for the help.

  9. #9
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36
    Well I must not be doing something quite right Itype in the following
    ME!Units In Stock = ME.Units In Stock + ME.Text44 once I did this and the went back to the form Access converted the code as the following =[ME.Units In Stock]=[ME.Units In Stock]+[ME.Text44] and is giveing me and error saying this " The expression you entered as the event property setting produced the following error: The object doen't contain the Automation object 'ME.Units In Stock'.

    this has me confused because the 'Units In Stock' box is part of the form data sheet

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Where are you putting the expression? It should be in a code procedure. I use only VBA, no macros.

    Post the entire code procedure for analysis.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36
    aahh that was the problem I was trying to use the code in the Expression builder when I should have used the Code Builder. thank you that helped me a lot plus I got to learn some more and Access.

  12. #12
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36
    Thank you that solved my problem

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

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