Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151

    Refreshing Subform Data


    I have a Table which has [Cust_ID], [Qty] and [Price]
    I have a Query of the above table with a an extra calculated field called [extended] which is [Qty] x [Price]
    I created a SubForm based on this Query which lists all these fields for each row for each record of [Cust_ID] which is on my main Form.
    I created another SubForm based on another Sum Query which totals the [extended] for each [Cust_ID]

    My issue is that as I enter new lines in the Subform with the details, the Total SubForm is not calculating the new total. If I program a DoCmd.Requery this works, but then it brings the form back to the first record.

    How can I have the Subform Total refresh and still stay on the same record.

    Thanks,
    Sam

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151
    Thanks. worked perfectly!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151
    I copied this code to another form and changed the field on this form. Yet it goes to the first record. Any idea why. The only difference is that the first form that worked the Key field was a number and i declared lngPK2 as Long, but for this new form the Key Field was a short text so I declared lngPK as string. Do I need to change the code to reflect the string instead of a number variable.

    Private Sub Test_Click()

    lngPK = Me.RMA

    On Error Resume Next
    DoCmd.RunCommand acCmdSaveRecord
    If (MacroError <> 0) Then
    Beep
    MsgBox MacroError.Description, vbOKOnly, ""
    End If

    Me.Requery
    'return form to original record
    With Me.RecordsetClone
    .FindFirst "RMA = " & lngPK
    If .NoMatch Then 'just in case another user deleted it in the interim
    MsgBox "Record not found!", vbCritical
    Else 'go to that record
    Me.Bookmark = .Bookmark
    End If

    End With

    End Sub

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try

    .FindFirst "RMA = '" & lngPK & "'"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151
    Didn't work

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151
    Open FRMAINfo and browse to the second or third record and click the save button and it will jump back to the first record.

    Test.zip

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Helps to use the actual field name.

    .FindFirst "[RMA#] = '" & lngPK2 & "'"

    You'll find symbols and spaces in your object names not worth the bother in the long run.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151
    Strange because I had tried that. Even tried now again and still doesn't work. Did it actually work for you?

  12. #12
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151
    I realized that after I was further into it and felt it was too much to change the field names and then have to change it in the queries, forms and reports. I started using _ for spaces in my new ones.

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Yes, the button worked once I changed that line. It would stay on whatever record I was on when I clicked it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    swenger is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    151
    Can you repost your version of the file because I made the same changes and it's not working for me.

  15. #15
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Here you go.
    Attached Files Attached Files
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Refreshing Form and Subform
    By faythe1215 in forum Forms
    Replies: 6
    Last Post: 04-21-2016, 04:51 PM
  2. Refreshing a subform
    By RobRoy in forum Forms
    Replies: 8
    Last Post: 07-22-2013, 04:19 PM
  3. Replies: 7
    Last Post: 11-13-2012, 01:44 PM
  4. SubForm not refreshing
    By hawkins in forum Access
    Replies: 2
    Last Post: 08-16-2011, 04:30 PM
  5. Refreshing a subform?
    By Shag84 in forum Forms
    Replies: 4
    Last Post: 08-07-2011, 10:07 AM

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