Results 1 to 5 of 5
  1. #1
    Join Date
    May 2009
    Posts
    41

    Unanswered: How do you anchor a text/combo box control to a tab control?

    I noticed when I created a text box directly inside a page, it becomes anchored to it, so that when you move the page around the form, the text box moves with it.

    I had a combo box that I hadn't created inside the page, rather outside of it on the form, and when I positioned it inside the page, it isn't anchored like the text box, but still to the form.

    Is there a combo box property that can specify what object it's anchored to?

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    If it's created outside the page, I don't think you can move it within the page. I would create a new one in the page (or try a copy/paste). Sometimes it's a little tricky adding a control within a page. You have to make sure the "Page" is selected (it should turn the page a different gray) and then insert the control (making sure the gray shows when inserting). Otherwise, just copy/paste the text box already in the page and then change the control to a combobox. I've never seen a property for it but maybe there is in MSAccess 2007.
    Last edited by pkstormy; 06-08-09 at 00:32.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    If it's created outside the page, I don't think you can move it within the page.
    Yes you can, but it's tricky! The secret to moving a control (combobox in this case) off of the form onto the page of a tabbed control is that you can't drag it onto the tabbed page!

    Instead, you have to
    1. Select the control
    2. Cut the control
    3. Select the proper page (not the whole tabbed control)
    4. Paste the control
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Agreed with Missinglinq. Only way to get existing objects into a tab is to cut and paste them there.

    When you do, you'll lose links to code -- if you have [Event Procedure] for your AfterUpdate for example, it will not be there afterwards. For this reason, take note of which ones are used and then you'll have to set them back to "[Event Procedure]" after you have pasted them into the tab.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  5. #5
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Trekker is correct on the controls being 'dis-connected' when cut and pasted on the tabbed pages. If you're talking about a single control being moved or a couple of controls being moved, you can 're-connect' them by selecting the control, then going to the Properties Sheet and clicking on the needed event as if creating the Event Procedure for the first time. You'll be taken to the code window and the control and event will be 'connected.'

    If you're talking about a large number of controls, however, this approach is somewhat tiresome. You can use code in the Form_Load event to 're-connect' Controls and their Event Procedures.

    This routine is based on code originally posted by ADezii a moderator on Bytes.com. It causes controls that have been moved from a standard form onto pages of a tabbed page control to be "re-connected" to their underlying code. If you should try to modify it, in order to include other type of controls/event procedures, be sure that you only try to re-connect controls to events that are appropriate! In other words, you can re-connect Command Buttons, Comboboxes and Labels to their OnClick events, but if you attempt to re-connect those same three control types to their AfterUpdate events, you will throw an error, because Labels don’t have AfterUpdate events!

    This code will reset some of the more commonly used controls/events.

    Code:
    Private Sub Form_Load()
    Dim ctl As Control
    
    For Each ctl In Me.Controls
    If (TypeOf ctl Is TextBox) Or (TypeOf ctl Is ComboBox) Or (TypeOf ctl Is CommandButton) Then
    If ctl.OnClick = "" Then
    ctl.OnClick = "[Event Procedure]"
    End If
    End If
    Next
    
    For Each ctl In Me.Controls
     If (TypeOf ctl Is TextBox) Or (TypeOf ctl Is ComboBox) Then
       If ctl.AfterUpdate = "" Then
         ctl.AfterUpdate = "[Event Procedure]"
       End If
     End If
    Next
    End Sub
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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