tgl btn and tab ctrl questions

  • Thread starter Thread starter Angi
  • Start date Start date
A

Angi

Since, I can't move the tabs on a tab control to the side in Access, I
created an option group with toggle buttons to control the tabs.

My problem is, when I click on the btn, it doesn't "toggle" or de-press
anyway.

Also, the only way I could figure out how to refer to the tab I want is
to use the setfocus event. It works, but isn't what I wanted. I just
want the tab to change when the toggle is pressed. I've tried
IsVisible, Enabled...etc..keep getting "Compile error: Invalid use of
property". I've done the searches, but I can't find one that deals
with custom controls for a tab control. Can someone help me?? TIA!

Here's my code:

Private Sub tglContacts_MouseDown(Button As Integer, Shift As Integer,
X As Single, Y As Single)
Me.pg02.SetFocus
End Sub
 
Angi said:
Since, I can't move the tabs on a tab control to the side in Access, I
created an option group with toggle buttons to control the tabs.

My problem is, when I click on the btn, it doesn't "toggle" or
de-press anyway.

Also, the only way I could figure out how to refer to the tab I want
is to use the setfocus event. It works, but isn't what I wanted. I
just want the tab to change when the toggle is pressed. I've tried
IsVisible, Enabled...etc..keep getting "Compile error: Invalid use of
property". I've done the searches, but I can't find one that deals
with custom controls for a tab control. Can someone help me?? TIA!

Here's my code:

Private Sub tglContacts_MouseDown(Button As Integer, Shift As Integer,
X As Single, Y As Single)
Me.pg02.SetFocus
End Sub

Angi -

Do I understand correctly what you're trying to do: have an option
group composed of toggle buttons to the side of the tab control, and
change pages on the tab control based on which button in the option
group is currently "pushed"? If that's what you're trying to do, I've
done it in one of my apps. It's not tricky, but you're going about it
the wrong way.

First, assign each option button in the group an OptionValue property
that corresponds to the page index of the tab control page you want to
be shown when that button is clicked. For example, if you have three
tab pages and three option buttons, set the OptionValue property of the
first button to 0, the second button to 1, and the third button to 2.
The numbers start at 0 because the tab pages are numbered starting from
0, not from 1.

Now, create an AfterUpdate event procedure for the option group like
this (substitute your own names for the option group and the tab
control):

'----- start of code -----
Private Sub optPageButtons_AfterUpdate()
Me!tabMyTabControl = Me!optPageButtons
End Sub

'----- end of code -----

In the above, "optPageButtons" is the name of the option group itself
(not any individual option button), and "tabMyTabControl" is the name of
the tab control. Assigning to the value of the tab control changes the
currently visible tab page.

Now, just in case it's possible for the tab control to change pages
without your clicking on any of the "page" buttons in the option group,
we need a line of code in the tab control's Change event to make sure
the option group always reflects the current page. That code looks like
this:

'----- start of code -----
Private Sub tabMyTabControl_Change()

' Make sure optPageButtons reflects the tab we're on.
Me!optPageButtons = Me!tabMyTabControl

End Sub

'----- end of code -----

You may or may not also need code in the form's Current event, to keep
the tab control in sync with the option group:

'----- start of code -----
Private Sub Form_Current()
Me!tabMyTabControl = Me!optPageButtons
End Sub
'----- end of code -----

Or you may want to always start each record with a specific tab page
showing, in which case you'd write the aabove more like:

'----- start of alternate code -----
Private Sub Form_Current()
Me!optPageButtons = 0 ' maybe
Me!tabMyTabControl = Me!optPageButtons
End Sub
'----- end of code -----

And that's all you need -- unless, of course, I've forgotten something,
but try that and see how it works for you.
 
Dirk,
Ahhhh....<sigh> of relief that is! I knew there was a way and I knew
I was doing it wrong!! Everything works great! I didn't need the
Change event since the tab ctrl is set to show nothing (unless there's
a way to change tabs without me knowing). The option group controls it
all. Thank you so very much!!!

Gratefully,
Angi
 
Dirk,
I put the Change event in there. I have command buttons that jump from
page to page too, so thank you again for that!!

Ang
 
Back
Top