Tabbed control help

neideb

Registered User.
Local time
Today, 00:31
Joined
Oct 9, 2001
Messages
42
Hi, I created a form to select client name. Double click on list box selection and wish to open another form that has a subform in control tab number 2.
I could not find any help in previous posts. Tks for any help.

Here is the code:

Private Sub SearchResults_DblClick(Cancel As Integer)
On Error Resume Next

Dim stDocName As String
Dim stLinkCriteria As String
Dim frm As Form

Set frm = Forms!SelectName
DoCmd.Echo False
stDocName = [Forms!FrmMainFrm!FrmResultSub.Form.ControlName ???
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord acDataForm, stDocName, acNewRec
stLinkCriteria = "[IdName]=" & Me![SearchResults]
Set frm = Nothing
DoCmd.Echo True
DoCmd.Close acForm, "Forms!SelectName", acSaveNo

End Sub
 
Tks John, I have already read the article you mentioned.
Maybe the problem is to open the form from another form where I select name in a listbox.
The main form shows ClientID and other info.
The subform that is shown in the tab shows info like ClientID, VisitID and other info related to Visit.
After I select the name I am searching I double click the name in list box and I wish I could open the main form and go directly to the tab where there is the subform so that I can add a new record.
Tks again for any help.:confused:
 
Given that you are dealing with a Subform, perhaps this link will help you get the correct syntax.
 
My code is as follows now but still not working. I can open the main form but the tab is not been selected.

stDocName = [Forms!FrmMainForm!FrmSubForm.Form.TabControl.Pages (2)]

Also, I need to open the form in a new record.
Tks for yr help.
 
Have you changed the highlighted areas to match the reality of your form and control names?

Code:
stDocName = [Forms![COLOR="Red"]FrmMainForm[/COLOR]![COLOR="Red"]FrmSubForm[/COLOR].Form.[COLOR="Red"]TabControl[/COLOR].Pages (2)]
 
Hi Paul,
Yes I did that. Still not working.
I had a combobox to search name in the subform but I had problems of duplicates. The search code I already have allows me to find any word in list (like *) so I decided to implement it in another form.
Tks again.
 
I think you need to do this in two steps:

Code:
'Open the main form:
DoCmd.OpenForm "FrmMainForm"

'Then set the focus to the page 2 tab (here's it is called Page2)
Forms!FrmMainForm!Page2.SetFocus

If you prefer, you can use:

Forms!FrmMainForm!TabControl.Pages(1).SetFocus


Note that the index 1 is the second page because the index starts at zero (I think).

Chris
 
Chris, it worked... tks to you and John
I used Forms!FrmMainForm!TabControl.Pages(1).SetFocus
Now I will work to go to new record. Maybe I have to mention the MainForm and subform.
I will let you know.
You are the best access forum. I learn a lot with you all.
 

Users who are viewing this thread

Back
Top Bottom