Results 1 to 11 of 11

Force a Requery from general module

  1. #1
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,059

    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
    Ajax is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    5,699
    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 is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,059
    Function is started from a Right-Click "Action"

    No luck with:

    Code:
    Forms("MainPop").Requery

  4. #4
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,059
    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
    Ajax is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    5,699
    '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 is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,059
    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 online now Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    7,574
    FYI -
    From Post #4
    Subsequent attempts yield the condition shown in the pic below:
    "Invalid Attachment" Error. Pic won't/can't open.
    HTH
    -----
    Steve
    --------------------------------
    "Veni, Vidi, Velcro"
    (I came; I saw; I stuck around.)

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

    Click image for larger version. 

Name:	000.jpg 
Views:	17 
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 is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,059
    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 Hacker
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    598
    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.
    Please use the star below the post to say thanks if we have helped !

  11. #11
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,059
    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, 07:08 AM
  2. Replies: 5
    Last Post: 04-15-2015, 03:20 PM
  3. General Module - Implementing LiFo Stack
    By GraeagleBill in forum Programming
    Replies: 2
    Last Post: 05-13-2014, 12:15 PM
  4. Replies: 1
    Last Post: 11-18-2012, 05:24 PM
  5. Replies: 4
    Last Post: 05-16-2011, 03: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
  •  
Tech Forums: Microsoft Office Forums