Results 1 to 13 of 13
  1. #1
    jamarogers is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Location
    Mendenhall, MS
    Posts
    19

    Unhappy Preserving values for Old Records

    Hi All,
    Two steps forward and one back...I have a dilemma of preserving "SellPrice" for existing records in my OrderForm. I change the "CurrentSellPrice" in InventoryForm periodically, to apply to future orders. My OrderForm looks up "CurrentSellPrice" in Inventory and applies that value to the "SellPrice" for the Item on the OrderForm. This works fine for new orders (and old ones, IF I don't review them)! Problem occurs when I look back at an old order and the "DLookUp" triggers, then updates the SellPrice to the NEW CurrentSellPrice. Any ideas on how I could DeActivate ALL bells and whistles, once an OrderForm is committed?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Sell price is one of the situations when we break some of the RDBMS rules. Because of the need to keep the history, that value is a calculated (or looked up) value that is actually stored in a table field.

  3. #3
    jamarogers is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Location
    Mendenhall, MS
    Posts
    19
    So what's your point? That's what I said...SellPrice is "looked up"! That's my problem...When I change that price in the future (as my costs go up), then it is reflected in my old orders, as I peruse them! Solution????

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    The solution would depend on HOW you are looking up the price. Is it code? Is it in a query? Can you post the relevant portion?

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    The point is that you need to store the SellPrice in your underlying Table. You could do something like

    Code:
    If Me.NewRecord Then
     Me.SellPrice = DLookup(...)
    End If


    or

    Code:
    If Nz(Me.SellPrice, "") = "" Then
     Me.SellPrice = DLookup(...)
    End If

    Linq ;0)>

  6. #6
    jamarogers is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Location
    Mendenhall, MS
    Posts
    19
    I enter a PO and the following expression looks up the SalePrice (from Inventory), returns it. This is now my SalePrice for this current order...
    =DLookUp("[InvSPrice]","Inventory","[InvName]= Forms![SOs]![SOItems]![SOItNme] and [InvSize]= Forms![SOs]![SOItems]![SOItSize]")
    ...time progresses and my costs go up and I need to raise my SalePrice. I manually update Inventory SalePrice for this item to a higher value.
    Now, IF I peruse my old order (that had the OLD SalePrice), it automatically updates to the NEW SalePrice...I want to preserve the OLD SalePrice
    for the existing Orders, BUT I also want to visit them at a future date without having them updated to the CURRENT SalePrice. Hope this makes sense,
    as it seems like it would be a common problem...

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    It is a common problem that is usually solved by just storing the sale price as I've indicated. In your case, maybe you only execute the DLookup() *if* the field does not already have a value.

  8. #8
    jamarogers is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Location
    Mendenhall, MS
    Posts
    19
    Thanks to all for your input and help here, although you didn't provide a plethora of info.
    For others like me who aren't yet able to act on "tidbits" of info; Here's how to do it...
    1) Lookup the value you need from a Table and make this field "invisible".
    2) Create a 2nd field that is bound to the control you wish to preserve and make it visible.
    3) Create some simple code that executes AfterUpdate like, "Me.SOItPrice (visible field) = Me.LUInvSPrice(invisible field)"
    4) Assign the code to execute for a control (InventoryName in my case) that uniquely represents the record in question.
    This will fetch the SalePrice from InventoryTable, write to the SalePrice field in the form that's bound to the SaleOrderTable, and preserve the price for this Order.
    Note that clicking again on the InventoryName (in 4 above) will again update the SalePrice to that currently specifed in the InventoryTable. Thus
    you should somehow "LocK" this record AFTER you're through with ALL updates...that's my Next Question

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    It looks to me like you have no field for the SalePrice in the table as the DLookup() you posted in your Post # 6 appears to be in a query. Do you have a Field in the table for the SalePrice or do you have to look it up every time?

  10. #10
    jamarogers is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Location
    Mendenhall, MS
    Posts
    19
    You're correct that INITIALLY, I had no field for the SalePrice...it was just looked up and never saved. Now I have added a 2nd field that is bound to the SaleOrderTable.SalePriceField, to which is written the looked up value.

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    The sequence you described in Post # 8 seems overly complicated and excessive. If you have the SalePrice displayed on the form and bound then when you have enough parameters to determine the value then look it up and put it in the SalePrice Control IF it is a new record (Me.NewRecord = True), otherwise leave the control alone.

  12. #12
    jamarogers is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Location
    Mendenhall, MS
    Posts
    19
    Thanks for that...I sometimes can't see the forest for the trees. I have updated my (our) solution in Post#8...appreciate your patience and help. Now on to making that SalePrice PERMANENT (in the SaleOrder) so I can't carelessly overwrite, when I update it in Inventory.

  13. #13
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Another option would be to have a saleprice table that included the effective date of the price, and match up thataway.

    However, coming from the accounting side, I prefer to have the actual invoice price stored on the order detail records.

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

Similar Threads

  1. Preserving String variable formatting in text box
    By Monterey_Manzer in forum Forms
    Replies: 5
    Last Post: 06-18-2013, 09:39 AM
  2. QuickSort a ListView preserving ListSubItems data
    By DepricatedZero in forum Programming
    Replies: 3
    Last Post: 04-26-2013, 05:29 AM
  3. Replies: 2
    Last Post: 11-09-2012, 10:49 AM
  4. Replies: 1
    Last Post: 06-16-2010, 09:25 AM
  5. Creating top values with two records
    By avesamuel in forum Queries
    Replies: 0
    Last Post: 10-15-2007, 10:45 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