Tab Control question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bobh

    Tab Control question

    Hi All

    In AccessXP I have a tab control with 5 tabs and I went to requery a
    combobox if and only if the user is moving from one perticular tab. I
    have this in place right now (On Change event of the tab control) but
    it does not do exactly what I want as it requeries cboParty each the
    user clicks on a non-'Page28' tab.

    If Me.TabCtl10.Pag es.Item(TabCtl1 0.Value).Name <"Page28" Then
    Me.cboPARTY.Req uery

    in other words when the focus is moved FROM tab 'Page28' requery
    cboParty. I was hoping I do not have to add code to each tab to
    requery the control.
    bobh.
  • BruceB

    #2
    Re: Tab Control question

    On Oct 22, 1:16 pm, bobh <vulca...@yahoo .comwrote:
    Hi All
    >
    In AccessXP I have a tab control with 5 tabs and I went to requery a
    combobox if and only if the user is moving from one perticular tab. I
    have this in place right now (On Change event of the tab control) but
    it does not do exactly what I want as it requeries cboParty each the
    user clicks on a non-'Page28' tab.
    >
       If Me.TabCtl10.Pag es.Item(TabCtl1 0.Value).Name <"Page28" Then
    Me.cboPARTY.Req uery
    >
    in other words when the focus is moved FROM tab 'Page28' requery
    cboParty.  I was hoping I do not have to add code to each tab to
    requery the control.
    bobh.
    The problem is that once the change event is invoked there's no way to
    tell which tab page you've just come from unless you've manually
    tracked it yourself.

    I would do the following:

    In the (General) section of the form, declare a flag:

    dim mfRequery as Boolean

    Then in the change event of your tab control:

    Private Sub TabCtl0_Change( )

    If TabCtl0.Pages(T abCtl0).Name = "Page28" Then
    mfRequery = True ' flag to requery on the next change event.
    ElseIf mfRequery Then
    cboPARTY.Requer y
    mfRequery = False
    End If

    End Sub

    Note that this doesn't work if the user moves focus to anything but
    another page on this particular tab control. If all of your controls
    on this form are on pages of your tab control you should be fine.

    Also, if Page28 has focus when the form is first opened, you should
    add

    mfRequery = True

    to the form's load event. This will ensure that the combo box gets
    requeried the first time focus moves from Page28 (by default mfRequery
    is false when it is first declared).

    Bruce

    Comment

    • bobh

      #3
      Re: Tab Control question

      On Oct 22, 3:39 pm, BruceB <deluxeinformat ...@gmail.comwr ote:
      On Oct 22, 1:16 pm,bobh<vulca.. .@yahoo.comwrot e:
      >
      Hi All
      >
      In AccessXP I have a tab control with 5 tabs and I went to requery a
      combobox if and only if the user is moving from one perticular tab. I
      have this in place right now (On Change event of the tab control) but
      it does not do exactly what I want as it requeries cboParty each the
      user clicks on a non-'Page28' tab.
      >
         If Me.TabCtl10.Pag es.Item(TabCtl1 0.Value).Name <"Page28" Then
      Me.cboPARTY.Req uery
      >
      in other words when the focus is moved FROM tab 'Page28' requery
      cboParty.  I was hoping I do not have to add code to each tab to
      requery the control.
      bobh.
      >
      The problem is that once the change event is invoked there's no way to
      tell which tab page you've just come from unless you've manually
      tracked it yourself.
      >
      I would do the following:
      >
      In the (General) section of the form, declare a flag:
      >
      dim mfRequery as Boolean
      >
      Then in the change event of your tab control:
      >
      Private Sub TabCtl0_Change( )
      >
          If TabCtl0.Pages(T abCtl0).Name = "Page28" Then
              mfRequery = True ' flag to requery on the next change event.
          ElseIf mfRequery Then
              cboPARTY.Requer y
              mfRequery = False
          End If
      >
      End Sub
      >
      Note that this doesn't work if the user moves focus to anything but
      another page on this particular tab control.  If all of your controls
      on this form are on pages of your tab control you should be fine.
      >
      Also, if Page28 has focus when the form is first opened, you should
      add
      >
      mfRequery = True
      >
      to the form's load event.  This will ensure that the combo box gets
      requeried the first time focus moves from Page28 (by default mfRequery
      is false when it is first declared).
      >
      Bruce
      Hi Bruce,
      I'm sure I'll be able to add what you provided into my form, Thanks
      for your help
      bobh.

      Comment

      Working...