Results 1 to 4 of 4
  1. #1
    hamxa7 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2012
    Posts
    2

    Update Query Not Working Properly !

    Hi All ...
    I've been working on a stock control database for a pharmacy as a school project and have been right on track till now...
    I've made an update query to update the stock in the stock table by adding the quantity ordered from the order form using the unique serial number assigned to each medicine as the criterion... (I know this isn't the best practice...)
    It works fine when there two or less records are present regarding a serial number in the order table... but when there are more than two records presents it gives the following warning :-
    "You are about to update "n" number of rows" where n is the number of records present - 1 ...
    But it should give the following warning "ALWAYS" :-
    "You are about to update 1 row"
    After it gives the warning it updates the stock but does it in the following manner :-


    Qty Available(Stock Table) = [Qty Available (Stock Table) + Qty Ordered (Order Form)] * n (number of rows shown in the warning) ...
    I don't know what to do...

    A sample of my database has been attatched...
    -PS : Don't tell me to convert it to VBA because I have been told by my teacher not to use it as I will lose marks...
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    The UPDATE wants to update every record that has a balance greater than 0. Remove Medicine Order Table from the query. Not only is it interfering, it is not relevant.

    Use SetWarnings action in macro if you want to prevent the warning popups.

    Saving calculated data (data dependent on other data) is usually a bad idea. The data can get out of sync. Queries could determine balances with aggregate calculations. However, those queries can be somewhat complex. I do suggest that saving the order Total Price is unnecessary. This is a simple calculation that can be done when needed.

    You have the medicine Serial Number as the primary key in Stock table but you have combobox on form that saves the medicine Name into Order table. Then you have code saving the Serial Number. Why not set ControlSource to SerialNumber and BoundColumn property to 1, not 2?

    I understand saving the price into Order table because prices can change but will the medicine name ever change? Why duplicate it into the Order table? If the name was changed, would it make sense to have it reflected in all order records?
    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.

  3. #3
    hamxa7 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2012
    Posts
    2

    What To Do Next ?

    Thanks for the reply...
    I have removed the medicine name combo-box from the form ... and am now using a combo-box to determine the serial number ...I have also removed the orders window from the the query design .. but what am I supposed to do know ???

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Everything should be working now.
    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.

Similar Threads

  1. NotInlist Event not working properly
    By thanosgr in forum Programming
    Replies: 2
    Last Post: 06-14-2012, 01:46 PM
  2. access program not working properly!
    By accesshelpme in forum Access
    Replies: 1
    Last Post: 05-13-2012, 03:43 PM
  3. Count or DCount Not Working Properly
    By Chris1112 in forum Forms
    Replies: 3
    Last Post: 05-09-2012, 02:51 PM
  4. Delete SQL statement not working properly
    By Alexandre Cote in forum Programming
    Replies: 3
    Last Post: 10-18-2010, 12:56 PM
  5. Query on chart not working properly!
    By Sim_ in forum Queries
    Replies: 0
    Last Post: 10-28-2009, 09:38 AM

Tags for this Thread

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