Results 1 to 6 of 6
  1. #1
    smikkelsen is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Mar 2010
    Posts
    60

    Form Requry

    Hi, I am not that familiar with VB but I think this will be an easy thing to do. Just not sure how.


    I have a continuous form that has a button on each record that will open a single view form (showing only the record selected) with more detailed view. I want to update (requery) the continuous form once the detailed view is closed.

    I actually have 3 different continuous forms that all use this same detailed view form. So what I tried doing was write an on close command



    Code:
     
    Private Sub Form_Close()
    PR_Main.Requery
    PR_Archived.Requery
    PR_Delinquent.Requery
    End Sub
    The only problem is, this detailed view will only be opened by one of these three forms. So running this code gives me a run-time error '424' Object required. So I assume its becuase 2 of the 3 forms listed above are not open.

    So, the question is, is there a different better way to do this? or can I just put some sort of if statement like "if PR_Main is open, then PR_Main.Requery"
    I don't know how to actually write that in VB, but would it work?

    Thanks

  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,641
    For starters, I believe you need to correct syntax to refer to the form:

    Forms Refer to Form and Subform properties and controls

    You will probably get an error on forms that aren't open though, as you suspect. You can either use IsLoaded (more info in VBA help) to test each form to see if it's open, or use OpenArgs to pass the name of the form that opened this one, and use that to requery the appropriate form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    smikkelsen is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Mar 2010
    Posts
    60
    The openArgs thing you mentioned sounds like the cleanest way of doing this. I am a VB Newbie, would you point me in the right direction on where I can read about that? or give me an example?

    Thanks again for the help and time!

  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,641
    Along the lines of:

    DoCmd.OpenForm "SecondFormName", , , , , , Me.Name

    to open the second form, and (untested)

    Forms(Me.OpenArgs).Requery
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    smikkelsen is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Mar 2010
    Posts
    60
    Thanks for getting me on the right track! This is what I used, and it works great.

    For the first form (calling form)
    Code:
     
    Private Sub Command74_Click()
    Dim sWHERE As String
    sWHERE = "[ID] = " & Me.ID
    DoCmd.OpenForm "Main_Tracking_Details", , , sWHERE, , , Me.Name
    End Sub
    for the second form (detailed form that was open by first form)
    Code:
     
    Private Sub Form_Close()
    Forms(Me.OpenArgs).Requery
    End Sub
    Thanks again for the help!

  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,641
    No problem, glad it worked for you.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

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