Results 1 to 7 of 7
  1. #1
    jalal is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Posts
    17

    SellRate should get updated

    Hi
    I have developed an application for “Stock Verification” for a business establishment. I have used following 5 tables
    1. tblProduct 2. tblSupplier 3. tblClient 4. tblTrans 5. tblTransDetails
    Following is the field lists of the above tables

    A. tblProduct
    ProductID PK Autonumber
    ProductName text
    ProductCode text

    B. tblSupplier
    SupplierID PK Autonumber
    SupplierName Text

    C. tblClient
    ClientID PK Autonumber
    ClientName Text

    D. tblTrans
    TransID PK Autonumber
    SupplierID FK Number
    ClientID Fk Number
    TransDirection ( +1 for buying, -1 for Selling)
    TransDate Date
    BillNo text
    BillDate Date

    E. tblTransDetails
    TransDetailsID PK Autonumber
    TransID FK number
    ProductID FK number
    PriceEach currency
    TaxRate percent
    Quantity Number
    SellPrice Currency



    On the basis of tblTrans I created a query “qryPurchase” with following columns
    SupplierID
    TransID
    TransDirection (criteria 1)
    BillNo
    BillDate

    I have created a Form from qryPurchase as frmPurchase with above controls

    On the basis of tblTransDetails I Have created a query “qryPurchaseDetails” with following columns (qryPurchaseDetails will serve as SubForm of frmPurchase)

    TransDetailsID
    TransID
    ProductID
    PriceEach
    TaxRate
    Quantity
    BuyRatePriceEach*TaxRate)
    BuyAmount PriceEach*TaxRate*Quantity)
    SellRateBuyRate*.11) (0.11 is the profit margin)

    I have created the SubForm “frmPurchaseDetails” from qryPurchaseDetails

    Likewise I have created a Form “frmSales” and subForm “frmSalesDetails”
    On the basis of tblTrans I created a query “qrySales” with following columns

    ClientID
    TransID
    TransDirection (criteria -1)
    BillNo
    BillDate

    On the basis of tblTransDetails I Have created a query “qrySalesDetails” with following columns (qrySalesDetails will serve as SubForm of frmSales)

    TransDetailsID
    TransID
    ProductID
    SellPrice
    TaxRate
    Quantity

    The movement some product is purchased the system gives its sellRate as well.
    Upto here Everything is working fine.

    Since Buying price “PriceEach” of a product changes as a routine from one date to another date
    Obviously the “SellRate” also changes. And the new TransID goes on increasing. It is fine.

    The Problem:
    With the help of DLookup function I managed to get the “SellRate” from “qryPurchaseDetails”
    I gave the formula as =Dlookup(“SellRate”,”qryPurchaseDetails”,”ProductI D=” & ProductID) and I was successful to get the SellRate inscribed in the “qrySalesDetails”.
    But the movement the buying price “Priceeach” changes, the above formula gives the previous “SellRate” as it brings the SellRate of the product based on the previous TransID.

    While as I want that the system should give the latest sell rate on the basis on new buy rate, which I can’t get with the help of SQL or Query.

    It is requested to help me in the problem using VBA procedure or any other method
    Thanks
    Jalal

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Don't fully understand the issue as summarized by:
    But the movement the buying price “Priceeach” changes, the above formula gives the previous “SellRate” as it brings the SellRate of the product based on the previous TransID.

    While as I want that the system should give the latest sell rate on the basis on new buy rate, which I can’t get with the help of SQL or Query.
    Why would value be based on previous TransID?

    Is the DLookup in a textbox ControlSource?

    Is the issue that viewing existing records after price has changed means the price at time of transaction is not shown? How are you saving the price at time of transaction?
    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
    jalal is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Posts
    17

    SellRate should get updated

    Quote Originally Posted by June7 View Post
    Don't fully understand the issue as summarized by:
    Why would value be based on previous TransID?

    Is the DLookup in a textbox ControlSource?

    Is the issue that viewing existing records after price has changed means the price at time of transaction is not shown? How are you saving the price at time of transaction?
    Dlookup works correctly

    The movement some product is purchased the system gives its sellRate as well.
    Upto here Everything is working fine.

    Since Buying price “PriceEach” of a product changes as a routine from one date to another date
    Obviously the “SellRate” also changes. And the new TransID goes on increasing. It is fine.

    With the help of DLookup function I managed to get the “SellRate” from “qryPurchaseDetails”
    On “frmSalesDetails” I gave the formula as =Dlookup(“SellRate”,”qryPurchaseDetails”,”ProductI D=” & ProductID) and I was successful to get the same “SellRate” inscribed in the “qrySalesDetails”.
    On next transaction the movement the Business Establishment makes fresh purchases on new buying prices i.e. “PriceEach” changes, The system still works fine and the new “SellRate” as per new “PriceEach” is got on “frmPurchaseDetails”. But on “frmSalesDetails” the system does not displays the new “SellRate” instead the old “SellRate” is still shown.

    While as I want that the system should give the latest sell rate on the basis on new buy rate, which I can’t get with the help of SQL or Query.

    It is requested to help me in the problem using VBA procedure or any other method
    Thanks
    Jalal
    Attached Files Attached Files

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    The db you provided does not have query "qryPurchaseDetails" nor forms "frmPurchaseDetails" and "frmSalesDetails".
    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.

  5. #5
    jalal is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Posts
    17

    SellRate Should get updated

    Quote Originally Posted by June7 View Post
    The db you provided does not have query "qryPurchaseDetails" nor forms "frmPurchaseDetails" and "frmSalesDetails".
    I am sorry for the inconveneance

    The corrected db is attached now

    Thanks and regards

    Jalal
    Attached Files Attached Files

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    I don't understand why you are using DLookup in frmSalesDetails. The RecordSource for that form is qryTransDetailSell and all the fields needed to calculate the SellRate are available in that query, just as they are in qryPurchaseDetails. The only difference between the two queries is one has tblClient and one has tblCreditor. Could actually include tblClient and tblCreditor in one query and make that one query work for both forms by setting Filter property of the form to: TransDirection = -1 (or 1).

    SELECT tblTransDetail.*, tblProduct.Product, CLng(Nz(Round([Quantity]*[PriceEachEx],2),0)) AS AmountEx, CLng(Nz(Round([Quantity]*[PriceEachEx]*[TaxRate]/100,2),0)) AS Tax, [AmountEx]+[Tax] AS AmountInc, tblTrans.TransDate, tblTrans.TransDirection, tblCreditor.MainName, tblClient.MainName, [AmountInc]/[quantity] AS CostEach, [quantity]*[sellprice] AS [Total Amount], tblProduct.BrandID, tblProduct.SeriesID
    FROM ((tblClient RIGHT JOIN tblTrans ON tblClient.ClientID = tblTrans.ClientID) RIGHT JOIN (tblProduct RIGHT JOIN tblTransDetail ON tblProduct.ProductID = tblTransDetail.ProductID) ON tblTrans.TransID = tblTransDetail.TransID) LEFT JOIN tblCreditor ON tblTrans.CreditorID = tblCreditor.CreditorID;
    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.

  7. #7
    jalal is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Posts
    17
    Thanks Problem solved

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

Similar Threads

  1. Save the updated data
    By ramindya in forum Access
    Replies: 4
    Last Post: 03-18-2012, 09:14 PM
  2. autofill box is always updated as 0.
    By mejia.j88 in forum Forms
    Replies: 7
    Last Post: 11-08-2011, 07:15 PM
  3. records with different updated report_date
    By lizzywu in forum Reports
    Replies: 3
    Last Post: 10-27-2011, 01:28 PM
  4. Append only updated records
    By Fabdav in forum Queries
    Replies: 4
    Last Post: 10-10-2011, 11:17 AM
  5. macro to updated tables
    By Wrangler in forum Import/Export Data
    Replies: 1
    Last Post: 01-18-2006, 11:01 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