Results 1 to 8 of 8
  1. #1
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Tab out of field on subform, code interferring

    I am trying to update a calculated value form 2 fields on my subform. Using the formula below. How or where should I put this code? I had it on the after update event, but it would was trying to calculate and not allowing me to tab out of the field.
    As you can see, I need the field "Difference" which is not editable to show the difference between the 2 other fields.

    Me.Difference = [SetReOrderLevel] - [OnHand]

  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
    Why is field not editable? You were using AfterUpdate event for what? Seems to me that should work. Need more info. Post full procedure or db 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.

  3. #3
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    I was making the field Difference show the difference between SetReOrderLevel and OnHand on the after update event of the form.
    Found the problem. The main form was doing a requery on 2 fields that had their control source set to 2 fields on the subform so I could get the true result right away.
    Guess I can't.
    One field was to the control SetReOrderLevel and did a Requery on the before update event, likewise the other control named OnHand.

    Then the subform used the code on the after update event: Me.Difference = [SetReOrderLevel] - [OnHand]

    The point of all of this was to show the correct Inventory data after it was updated. I stopped using a requery and used a refresh.
    Me.Difference = [SetReOrderLevel] - [OnHand] is causing the problem, it just requeries and you cant tab out of the field.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You found the problem so issue is resolved?
    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
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    NO! making me crazy. If I try to make the control show the difference between the other 2 it stops and just requeries.
    Is there another way to code this?
    I have tried;
    Me.Difference = [SetReOrderLevel] - [OnHand]

    AND

    Default Value of control Difference is =[SetReOrderLevel].[Value]-[OnHand].[Value]

    NO LUCK, First line of code stops, second does nothing.


    3 Fields: Getting the difference between 2 fields and set that value to the 3rd field.

    1.Field One;[SetReOrderLevel] ' Amount set to ReOrder if inventory falls below
    2.Field Two; [OnHand] 'Actual amount on inventory
    3.Field Three; [Difference] 'Difference between the 2. ReOrder this amount!

    Then update the form which is a Datasheet.(Subform)
    Last edited by burrina; 12-03-2012 at 01:02 AM. Reason: Further Explanation

  6. #6
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Ok, Here is my DB with Table and Form!

    I don't know why it is NOT letting me tab out and save the record. Can someone Please take a look and see? Notice the code that runs on the After Update Event of the form.

    Set The OnHand to ONE less than the SetLevel and keep tabbing to last field to see what happens.

    Thanks,
    Attached Files Attached Files
    Last edited by burrina; 12-03-2012 at 03:45 AM. Reason: Further Explanation

  7. #7
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    Me.Difference = [SetReOrderLevel] - [OnHand]
    Have I totally misunderstood the situation if I ask why you can't put = [SetReOrderLevel] - [OnHand] in the control source for Difference?

  8. #8
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Yes, I could.Good Morning to you! I have fixed the problem finally. Such a simple thing. Fixed it last night. Thanks for all the looks and replies. I wound up moving my code to the OnCurrent Event and doing a Requery, and all is well. Sheeessssh!


    Thanks,


    Good Suggestion By The Way

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

Similar Threads

  1. Replies: 8
    Last Post: 04-13-2012, 12:25 PM
  2. Replies: 16
    Last Post: 04-11-2012, 10:56 AM
  3. Replies: 5
    Last Post: 11-16-2011, 07:30 PM
  4. Replies: 7
    Last Post: 07-15-2011, 01:58 PM
  5. Write Code to Navigate from Subform to Subform
    By Swilliams987 in forum Programming
    Replies: 22
    Last Post: 02-04-2011, 11:30 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