Auto Fill for tab control

P

ploddinggaltn

I'm thinking this can be done with code rather than an invisable field but I
could use some help, here is my situation:

I have a form with a tab control on it...the form name is "frmCaseType".
There are 10 tabs to the tab control. I need to have the tab name prefill
into the "CaseID" field when the tab is selected. For example, if the tab
named "tabBlue" is selected, I need the "caseID" field to prefill with "Blue"
for that record. When the tab named "tabRed" is selected, I need the
"caseID" field for the record to prefill with "red". Is this possible? I
appreciate your help.
 
B

Brendan Reynolds

ploddinggaltn said:
I'm thinking this can be done with code rather than an invisable field but
I
could use some help, here is my situation:

I have a form with a tab control on it...the form name is "frmCaseType".
There are 10 tabs to the tab control. I need to have the tab name prefill
into the "CaseID" field when the tab is selected. For example, if the tab
named "tabBlue" is selected, I need the "caseID" field to prefill with
"Blue"
for that record. When the tab named "tabRed" is selected, I need the
"caseID" field for the record to prefill with "red". Is this possible? I
appreciate your help.


Private Sub tabTest_Change()
Me.TestText = Me.tabTest.Pages(Me.tabTest.Value).Name
End Sub

Where "TestText" is the name of the field or control to which the value is
to be assigned, and "tabTest" is the name of the tab control.

The Value property of the tab control returns the index of the currently
active tab.
 
P

ploddinggaltn

Thanks Brendan, I've tried the code but nothing happens. I was wondering if
it is because the TaskID field is on the form Detail section, not on the tab
control part. I did add TaskID field to the tab itself and it still didn't
work. I tried adding it to the OnClick command and that didn't work for me
either. Any suggustions why this isn't working for me? Thanks

Here is the code that I used:

'Private Sub tabBalancing_Change()

'Me.TaskID = Me.tabBalancing.Pages(Me.tabBalancing.Value).Name

'End Sub
 
P

ploddinggaltn

My mistake, I commented it out when it didn't do anything on my form. When
it wasn't commented out it didn't work, any ideas. Sorry for not pulling the
comments out. :)
 
B

Brendan Reynolds

Ah, I think I see the problem. Apparently, if you don't explicitly assign a
value to the Caption of the tab page, the Caption property returns an empty
string, even though the name of the page is displayed on the tab. If that's
what's happening, you can either assign a value to the Caption property
(either by typing it in the Properties window at design time or by assigning
it at run time in code) or you can use the Name property instead of the
Caption property.

--
Brendan Reynolds

ploddinggaltn said:
My mistake, I commented it out when it didn't do anything on my form.
When
it wasn't commented out it didn't work, any ideas. Sorry for not pulling
the
comments out. :)
 

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

Similar Threads


Top