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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding records inside tab control 1

Status
Not open for further replies.

tazardous

Programmer
Aug 22, 2002
58
US
I have a form, let's call it frmMain,
containing a subfrm, let's call it subfrmTabs,
that contains a series of tabs.

When a user clicks on a tab and enters a new record,
I want to be able to set a field in this new record to
the name of the tab they are working in. This way, the
record they add will be associated with that tab and will
only display while that tab is active.

In what event, and what code do I use to do this?

Thanks,
Taz
 
It sounds like you're using the tabs as a way to filter records, which is an interesting approach. If this is correct, I don't think you need to put the tab control on a subform, you can simply put it on your main form, and do a Format:Send To Back to put it in the background. Your controls are then superimposed over the form.

Regarding requerying, you could do the following:

Trap the OnChange event for the tab control:

Private Sub SetFilterToTab
Me.Filter = "(((Table1.c)='" & Me.TabCtl4.Pages(Me.TabCtl4.Value).Caption & "'))"
Me.FilterOn = True
End Sub

Private Sub TabCtl4_Change()
SetFilterToTab
End Sub

You will want to do the same for the Form Load event.

HTH
 
Hi,
The form has a parent table of it's own,
and the subform has a child table of it's own.

Yes, the tabs are a way of filtering the data. And the
filtering (for the sake of displaying existing records)
is working. (i.e. if I manually open the table directly
and add records, they appear 'under' the appropriate tabs
inside the form/subform).

The problem is getting the code in place to actually enter the name of tha tab into the new record to associate the new record with the current tab.

Brian
 
OK, the next step is to add code to the form's before update event procedure, like this:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.<fieldname> = Me.TabCtl4.Pages(Me.TabCtl4.Value).Caption
End Sub
 
The actual code

Me.ExamList=Me.tabtechinfo.Pages(Me.tabtechinfo.Value).Caption

works PERFECTLY and I thank you because I was getting no where trying to figure out the syntax.

Taz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top