none
How do I make a tabbed subform requery based on changes in another tabbed subform? RRS feed

  • Question

  • I have a form with a tab control, which in turn has 3 subforms on separate tabs.

    The first tab has records where the user fills in a quantity on a record.  if that quantity is > 0, I want that record to show up in the second tab.  The second tab is a query based on the records in the first tab, but only where quantity > 0.  I want it to requery automatically.

    I can put a Refresh Data button on the second tab and make it update like that, but a user could forget to do that.  I want that second tab to requery based on changes in the first tab.

    I tried putting something in TabCtl16.OnChange, but that did nothing.  I tried putting TabCtl16.[Shipping.requery, and that blew up, but I was also using a wrong subform name.

    In the AfterUpdate event of the quantity field, I tried :

     Forms![pl report header].Form![pl report final to ship].Requery
        
        Me.Parent.Controls![pl report final to ship].Requery

    and neither worked.

    Has to be a way to do this.

    TIA.


    Thanks, David



    • Edited by David_Ford Thursday, January 10, 2019 2:36 PM
    Thursday, January 10, 2019 2:07 AM

Answers

  • Hi David,

    Simply, if the name of your Tab Control is MyTabControl and the subform you want to query is on the second tab, then try:

    If Me.MyTabControl = 1 Then

    ...

    • Marked as answer by David_Ford Thursday, January 10, 2019 10:23 PM
    Thursday, January 10, 2019 3:52 PM

All replies

  • Hi David,

    One way is to use the Tab Control's Change event and use something like:

    If Me.TabControlName = 1 Then 'assuming the second subform is on the second tab
        Me.SecondSubformName.Form.Requery
    End If
    

    Hope it helps...

    Thursday, January 10, 2019 3:38 PM
  • Thanks for your reply.  This part doesn't make sense:

    If Me.TabControlName = 1 Then

    I probably need as exact a syntax as possible, given how easily this can go south.


    Thanks, David

    Thursday, January 10, 2019 3:43 PM
  • Hi David,

    Simply, if the name of your Tab Control is MyTabControl and the subform you want to query is on the second tab, then try:

    If Me.MyTabControl = 1 Then

    ...

    • Marked as answer by David_Ford Thursday, January 10, 2019 10:23 PM
    Thursday, January 10, 2019 3:52 PM
  • I ended up going with this, which is working.  I couldn't quite get the syntax to work with what you suggested, though it did point me in the right direction.  Thank you.  I didn't really matter if the user was moving from tab 1 to tab 2.  Just that tab 2 needed to be requeried.

    Private Sub TabCtl16_Change()

        Me.[pl report final to ship].Requery

    End Sub


    Thanks, David

    Thursday, January 10, 2019 10:23 PM
  • Hi David. Glad to hear you got it sorted out. Good luck with your project.
    Friday, January 11, 2019 4:18 PM