Results 1 to 6 of 6
  1. #1
    10 Gauge's Avatar
    10 Gauge is offline Getting the hang of it...
    Windows XP Access 2007
    Join Date
    Feb 2011
    Location
    Fredericksburg, VA
    Posts
    202

    Question Subform -> Parent form requery not working correctly

    I have an AfterUpdate event set to fire after a new value has been entered that will requery a control on the parent form to recalculate the equation that it displays once the new entry has been input.



    For some reason it either doesn't do the math properly, or some times just doesn't work at all.

    However if I manually refresh the parent form it recalculates and displays the correct number. I am wondering why my requery AfterUpdate is causing the parent form control to miscalculate?

    VBA I am using for the Requery:

    Code:
    Private Sub PMEventUsage_AfterUpdate()
    Me.Parent!PMCountDown.Requery
    
    End Sub

  2. #2
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    I have had problems like this in the past. What exactly are you trying to achieve i.e. what is on your subform and main form and what calculations are you trying to do?

    Also, is the control on the main form bound or unbound?

  3. #3
    10 Gauge's Avatar
    10 Gauge is offline Getting the hang of it...
    Windows XP Access 2007
    Join Date
    Feb 2011
    Location
    Fredericksburg, VA
    Posts
    202
    Quote Originally Posted by SoftwareMatters View Post
    I have had problems like this in the past. What exactly are you trying to achieve i.e. what is on your subform and main form and what calculations are you trying to do?

    Also, is the control on the main form bound or unbound?
    Here's my calculation function (which is an unbound text box on the main form, referencing two different subforms on the main form)

    =DMax("PMEventUsage","PMEvents","AssetID = " & [Forms]![Asset Details]![AssetID])+DLookUp("PMInterval","AssetTypes","AssetTypeID = " & [Forms]![Asset Details]![AssetTypeID])-DMax("Usage","AssetUsage","AssetID = " & [Forms]![Asset Details]![AssetID])

  4. #4
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    Try putting your calculation in an unbound control in the footer of the subform and then set the recordsource of the control on your main form to target the one on the subform.

  5. #5
    10 Gauge's Avatar
    10 Gauge is offline Getting the hang of it...
    Windows XP Access 2007
    Join Date
    Feb 2011
    Location
    Fredericksburg, VA
    Posts
    202
    Sorry to sound like a noob, which I am. I've got the new unbound control with the calculation at the footer, what's the syntax for pointing the control source of the box on my main form to the control in the footer? I tried Me.PMCalcFooter and [Forms].[Asset Details].[PMCalcFooter] and neither of those worked.

    TIA!!!

    Edit: I guess an "=" at the beginning always helps... Ok now it's displaying. Let me add some test numbers and see if it's working now.

  6. #6
    10 Gauge's Avatar
    10 Gauge is offline Getting the hang of it...
    Windows XP Access 2007
    Join Date
    Feb 2011
    Location
    Fredericksburg, VA
    Posts
    202
    Ok so it works great if I am updating subform 1 (i have afterupdate events set to requery both controls on the main form so that the number is always correct.) However for some reason if I make the update to subform 2 it does not requery the controls on the main form (but the code between both afterupdate events matches perfectly) so I am kind of at a loss as to why it's working one way, but not another. If I manually refresh the main form it calculates properly.

    EDIT: Got it to work by first adding a requery on the subform.

    Thanks for the help SoftwareMatters!

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

Similar Threads

  1. Replies: 0
    Last Post: 01-27-2011, 09:58 AM
  2. Replies: 1
    Last Post: 12-22-2010, 01:28 AM
  3. Replies: 2
    Last Post: 10-19-2010, 11:05 AM
  4. Split Form not working correctly
    By Brian62 in forum Access
    Replies: 29
    Last Post: 02-16-2010, 05:43 PM
  5. Search field is not working correctly
    By jakeao in forum Programming
    Replies: 9
    Last Post: 05-18-2009, 07:47 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