Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using TabControl to enter value into a field?

Status
Not open for further replies.

jhovel

Technical User
Sep 5, 2006
2
AU
Hi,
I'm not a programmer, but get myself into these projects too deep too easily... ;)

I've developed an Access database for my work (no IT support there) with a data entry form that contains mainly a tab control. It runs on a Pen PC and I wish to use the tab name chosen by a user to be entered into a field in a record.
I've played (unsuccessfully) with the OnChange property, but the tabs ar "sticky" so that multiple records entered by on the same tab "page" don't invoke a "change".
I guess what I need is something like a Case structure that identifies which tab is open and enters the name of the tab as a value into the record....
I'm lost as to how to achieve this.
For the moment, I've used a drop-down combo box to let the users select the choice to enter (their profession) - but then they still have to make the same choice on the tab control to get to see the "page" where they fill in the rest of the data for their records.
All tab pages are the record source for the same table - so subforms are not necessary (as I see it).
Anyone able to help? This is driving me crazy...
Cheers,
Joe
 
Use the BeforeUpdate event procedure of the form.
Tip: the value of a a TabControl object is the page number.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Bloody great! That set me on the right path. Thank you!
I ended up using a case statement to select the record entry based on the page number. It works!

Private Sub Form_BeforeUpdate(Cancel As Integer)

' Enter Tab label value into Practitioner Type field

Dim strTabText As String

Select Case Me!TabCtl1.Value 'Returns Page Index

Case 0 'Page Index for Page 1
strTabText = "Nurse"
Case 1 'Page Index for Page 2
strTabText = "Doctor"
Case 2 'Page Index for Page 3
strTabText = "Dentist"
Case 3 'Page Index for Page 4
strTabText = "Physio"
Case 4 'Page Index for Page 5
strTabText = "Psych Nurse"
Case 5 'Page Index for Page 6
strTabText = "Optometr"
Case 6 'Page Index for Page 7
strTabText = "Dietician"
Case 7 'Page Index for Page 8
strTabText = "Psychiatrist"

End Select

Me!Practitioner_Type.Value = strTabText

End Sub

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top