Tab control Changes

C

Chuck

I am using Access 2000
I have a form (Prospects) with a Tab Control (Tabctl21) and some text box
controls on a Tab called "Add Prospects", Page Index =1. I'm trying to turn
Enable Property off on these controls using on Change event procedure. I cant
get the controls to change only for this tab (Im using msgbox to test). Its
happeing for all tabs. here is the code i am using:

I've tried many combinations where the ????? are including Page.count to no
avail.

Private Sub TabCtl21_Change()
Dim ctrl As Control
Dim tci As Integer
tci = Me.TabCtl21.?????????
If tci = 1 Then
MsgBox "You are on Page AP"
Else
MsgBox "You are NOT on Page AP"
End If
End Sub

Can you show me the entire code i should use.
 
T

tina

the value of a tab control is equal to the page index of the currently
selected page in the control. so when you select the page whose page index
is 1, then

Me!Tabctl21 = 1

if you're wanting to *toggle* a control's Enabled property based on which
page of a tab control is currently selected, you can use some simple toggle
code, as

Me!ControlName.Enabled = (Me!Tabctl21 = 1)

in the above code, when the index number of the currently selected tab page
is 1, then the value of Tabctl21 = 1. Access evaluates the expression
(Me!tabctl21 = 1)
as True. so the setting of the Enabled property (of the named control) =
True.

if you want to *dis-able* the property when the specified page is currently
selected, alter the code slightly, as

Me!ControlName.Enabled = Not (Me!Tabctl21 = 1)

in the above code, (Me!Tabctl21 = 1) evaluates to True, so the expression is
Not True....in other words, False.

though i have to wonder why you're doing this. in Form view, the user can
only see the currently selected tab page at any given time. why DISable a
control only when a user moves to another page? s/he can't "get to" that
control without going to back the page it's on anyway. conversely, why
ENable a control when the user moves to another page? again, s/he can't get
to that control anyway, at that point.

hth
 
C

Chuck

Thanks, i see where i made the syntax error.
There are multiple controls on the form so i think i will run a loop
I maybe going about this the wrong way but when the user goes to the "Add
new Prospect" Tab, the existing fields are populated from a previous control
on another tab - so i dont want the user to over type what is there. I will
also have a button to "add new record" which can then turn the enabled=yes
property true for all the controls.

I guess i could disable edit property but i wanted a visual grey-out look so
the user had to hit the "add button" to start the add process.

Can you think of another way to accomplish this?
 
T

tina

okay, i understand why you're doing it, and running a loop on the controls,
setting the property with the toggle code as you loop, sounds reasonable to
me.
when the user goes to the "Add
new Prospect" Tab, the existing fields are populated from a previous control
on another tab - so i dont want the user to over type what is there.

the above description does give me a bit of a chill, though. you're not
storing duplicate data in two tables, are you? or in "extra" fields in the
same table?

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top