Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2011
    Location
    Queens
    Posts
    20

    Unanswered: Linked Combo-Box & Saved Records

    This is a follow-up to this: http://www.dbforums.com/microsoft-ac...o-box-tab.html

    When I flip through older saved records I noticed the Combo-box does not hold the tab it is related to.

    I understand the logic that the Event Procedure is only in AfterUpdate and when I go back to the record I am not touching the Combo-box therefore it has no instructions. Is there an easy solution that forces the tab to reflect what is already in the Combo-box if the record is saved?

    Thank you

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    If the combo is bound (i.e; if its value changes when the form moves from one record to another), you can use the same statement as the one in Combo_AfterUpdate, this time in the event handler for the Current event of the form:
    Code:
    Private Sub Form_Current()
    
        Me.TabCtl0.Pages("Tab" & Me.Combo_SelectTab.Value).SetFocus
    
    End Sub
    Have a nice day!

  3. #3
    Join Date
    Nov 2011
    Location
    Queens
    Posts
    20
    Ok I'll give that a shot on Monday. Have a great weekend

  4. #4
    Join Date
    Nov 2011
    Location
    Queens
    Posts
    20
    Quote Originally Posted by Sinndho View Post
    If the combo is bound (i.e; if its value changes when the form moves from one record to another), you can use the same statement as the one in Combo_AfterUpdate, this time in the event handler for the Current event of the form:
    Code:
    Private Sub Form_Current()
    
        Me.TabCtl0.Pages("Tab" & Me.Combo_SelectTab.Value).SetFocus
    
    End Sub
    I have tried it and when I search for older tickets it works out great. But when I created a new ticket I get an error:

    Run-time error '2467': The expression you entered refers to an object that is closed or doesn't exist.

    I click on DEBUG and it takes me to the code I just entered.

    My version looks like this:
    Code:
    Private Sub Form_Current()
    
        Me.TabCtl82.Pages("Tab" & Me.Combo_SelectTab.Column(0)).SetFocus
    
    End Sub
    It's like the Form code is taking precedence over the Combo-box code. When it sees there is no "current" data in the new ticket it doesn't like it.

  5. #5
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    This is normal as Me.Combo_SelectTab.Column(0) is Null for a new record, while this situation can never happen when you select a value in the combo.

    Use:
    Code:
    Private Sub Form_Current()
    
        If Not IsNull(Me.Combo_SelectTab.Value) Then 
            Me.TabCtl0.Pages("Tab" & Me.Combo_SelectTab.Value).SetFocus
        End If
    
    End Sub
    Have a nice day!

  6. #6
    Join Date
    Nov 2011
    Location
    Queens
    Posts
    20

    Thumbs up

    This is working perfectly!

    Code:
    Private Sub Form_Current()
    
        If Not IsNull(Me.Combo_SelectTab.Value) Then
            Me.TabCtl82.Pages("Tab" & Me.Combo_SelectTab.Column(0)).SetFocus
        End If
    
    End Sub
    Maybe it shouldn't but it is. I can't remember why I chose the
    Code:
     Column(0)).SetFocus
    .. I think it might have had something to do with new records carrying over the choice in the combo-box made in the previous record?

    Thanks again for all your help

  7. #7
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •