Results 1 to 2 of 2
  1. #1
    andi-r is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    1

    Question Access Help!

    I have 2 tables,one a called allshoprecords which have these fields(Id(autonumber),productname(text),quantity(n umber)),other table is called invoice which have these fields (IdInvoice(autonumber),productname(text),quantity( number)).I create a form in table called invoice and i put a print button.And i need to know which is the code when i click in print button to do this action (allshoprecords.quantity-invoice.quantity).Please help Meee!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You are trying to maintain a cumulative net quantity for each product in allshoprecords? Ideally, in a relational database, this net quantity would be calculated when needed, not saved to table. The relational concept would be to save raw data (in/out transaction records for products) and perform aggregate calcs using the transactions. What you want to do will probably require an SQL UPDATE action and has the risk that the button could accidentally be clicked repeatedly.

    The VBA code in the button click event could be like:
    CurrentDb.Execute "UPDATE allshoprecords SET quantity = quantity-" & Me.quantity & " WHERE productname='" & Me.productname & "'"

    Have you looked at the Northwind template database? Perhaps it would suit your needs or you could get ideas from it.
    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.

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