Move existing objects into tab control (1 Viewer)

April15Hater

Accountant
Local time
Today, 15:22
Joined
Sep 12, 2008
Messages
349
Hello-

On my form I have several objects that I would like to separate amongst a few tab controls. The only way I can get an object to attach itself to a tabbed page is by making a new object. I'd like to use the existing objects so I don't have to go back and reprogram everything. Does anybody know how to make existing objects attach to a tabbed page?

Thanks!

Joe
 

MarkK

bit cruncher
Local time
Today, 12:22
Joined
Mar 17, 2004
Messages
8,179
Ya, select existing objects, Cut them, select destination tab page and Paste them. Also, you'll have to manually rewire your event handlers, so if you cut and paste a button, for instance, you'll have to go to the event property sheet and put '[Event Procedure]' back in the OnClick property.
 

April15Hater

Accountant
Local time
Today, 15:22
Joined
Sep 12, 2008
Messages
349
ahh! Cut! I was trying to copy. Gotcha. Too bad Access 07 didn't fix that event handler deal.
 

George-Bowyer

Registered User.
Local time
Today, 20:22
Joined
Dec 21, 2012
Messages
177
I have been struggling with this and have "discovered" something that isn't in the answer above.

You (well, I, anyway) can't cut-and-paste straight into a virgin tab page. You need to "initialise" it by creating a text box or something on the new tab page first. Then the cut-and-paste will work. Then you can delete your text box.

If you try pasting without "initialising" first, nothing happens at all. Paste is disabled.
 

missinglinq

AWF VIP
Local time
Today, 15:22
Joined
Jun 20, 2003
Messages
6,423
No reason you should have to create a Textbox on the Tabbed Page before cutting and pasting an existing Control on it...not really sure what is going on, there...but here's a hack for automatically 'reconnecting' moved Controls to their Event Procedures:

Courtesy of ADezii, at Bytes.com, this code will "reconnect" Controls to some selected events (OnClick and AfterUpdate, in this example.) It can be modified for other Events, and has the advantage of updating a large number of Controls without doing them one by one.

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
Linq ;0)>
 

jdraw

Super Moderator
Staff member
Local time
Today, 15:22
Joined
Jan 23, 2006
Messages
15,379
For anyone landing here--this is a "continuation" of an 8 year oldpost...
but 'linq has a solution.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 20:22
Joined
Jul 9, 2003
Messages
16,271
Code:
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
Linq ;0)>

An alternative to the above:-

Code:
    For Each Ctrl In Me.Controls
        Select Case Ctrl.ControlType
            Case acCheckBox, acComboBox, acLabel, acListBox, acOptionButton, acOptionGroup, acTextBox, acToggleButton

If ctl.OnClick = "" Then
    ctl.OnClick = "[Event Procedure]"
End If
 
Last edited:

George-Bowyer

Registered User.
Local time
Today, 20:22
Joined
Dec 21, 2012
Messages
177
For anyone landing here--this is a "continuation" of an 8 year oldpost...
but 'linq has a solution.

I know it's an old link, but my search for answers brought me here, unsuccessfully, so i thought I'd share what I found for the benefit of anyone else searching the same thing...
 

jdraw

Super Moderator
Staff member
Local time
Today, 15:22
Joined
Jan 23, 2006
Messages
15,379
No problem George. We encourage posters to post solutions or even dialogs without final solution. Someone, sometime may just be helped by such posts/threads.
My only intent was to advise on the age of the thread. Many times we see posters responding to a question asked years ago. I know because I have done it myself.

Hopefully responses by 'Linq and Tony (Uncle Gizmo) have resolved your issue.
 

Users who are viewing this thread

Top Bottom