Results 1 to 11 of 11
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Force a Requery from general module

    Given a function executing subordinate to a form, how can that function force the form to Requery its RecordSource? Obviously, the general module isn't a child so trying to reference a Parent makes no sense. And, the DoCmd.Requery method refers to controls so my imagination is failing me today?

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    if the form is passed as a parameter to your function, you can requery that, otherwise perhaps something like

    forms.myform.requery

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Function is started from a Right-Click "Action"

    No luck with:

    Code:
    Forms("MainPop").Requery

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    For the time being, I coded with a close and re-open: (You might notice the SQL DELETE which deletes a record from the forms RecordSource and hence the need to Requery)
    Code:
    Select Case TaskName
        Case "Delete"
            If MsgBox("DELETE """ & Trim(strSelTitle) & """ from MyLinks?", vbYesNo, "Deleting Links") = vbYes Then
                CurrentDb.Execute "Delete * FROM tblLinks WHERE LinkID = " & intSourceID
                Call CompileLst
                DoCmd.Close acForm, "MainPop"
                DoCmd.OpenForm "MainPop", acPreview, , , , acDialog
                Exit Function
            Else
    The problem with the above method is that on subsequent use of the Right-Click "Action" after the re-Open will only work one time. Subsequent attempts yield the condition shown in the pic below:
    Attachment 34676

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    'no luck' tells me nothing and wasn't what I suggested.

    You could consider perhaps screen.activeform but I don't have time for 20 questions to determine the real situation and what 'no luck' means.

    Good luck with your project

  6. #6
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    I'm sorry, you suggested forms.myform.requery so I tried your suggestion using reference to the forms collection thus Forms("MainPop").Requery as posted in my reply and that did not work.

  7. #7
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    FYI -
    From Post #4
    Subsequent attempts yield the condition shown in the pic below:
    "Invalid Attachment" Error. Pic won't/can't open.

  8. #8
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Not Sure what happened there.......... here it is

    Click image for larger version. 

Name:	000.jpg 
Views:	18 
Size:	35.7 KB 
ID:	34678

    The first time I use it when the form opens there's no check mark. As soon as I use the "Delete Link" function everything works as expected, but 2nd attempt shows the check box and the functionality behaves as though the right-click popup menu is disabled.

  9. #9
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    I'll give screen.activeform a shot in the AM. It did occur to me a bit ago that perhaps a Requery on the main form might not necessarily mean that the sub-forms it contains also refresh their RecordSource. If they don't I might be asking something of Access that it simply doesn't support?

  10. #10
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    If the subforms are linked through a Master /Child record then they will refresh automatically.

    Might be worth uploading a stripped down version to play with, as context menu's are a bit of a pain to debug.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  11. #11
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    If the subforms are linked through a Master /Child record then they will refresh automatically.
    I was of the belief that the sub-forms would also refresh so thanks for confirming that.

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

Similar Threads

  1. How to cause a form event to fire from a general module
    By GraeagleBill in forum Programming
    Replies: 10
    Last Post: 09-04-2016, 08:08 AM
  2. Replies: 5
    Last Post: 04-15-2015, 04:20 PM
  3. General Module - Implementing LiFo Stack
    By GraeagleBill in forum Programming
    Replies: 2
    Last Post: 05-13-2014, 01:15 PM
  4. Replies: 1
    Last Post: 11-18-2012, 06:24 PM
  5. Replies: 4
    Last Post: 05-16-2011, 04:58 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