|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Set focus to certain tab on open
I have a form frm_OpenOption that on opening has 4 options.
*Add new *Search Existing *Cancel/Exit Reports & Correspondence The first 3* all do as they are supposed to which is open another form frm_MainPage and either create a new record, go to fld_SearchExisting or Close My problem lies with the Reports & Correspondence option. When clicked i would like it to open frm_MainPage and then setfocus to tab_Reports. There are four tabs in total, tab_Reports is #4. It contains images which link to certain reports and 1 combo box. I have tried the following code but get a compile error: Argument not optional The error line is in red. Is there are simple way to do this? Private Sub img_ReportsCorrespondence_Click() Dim stDocName As String Dim stLinkCriteria As String stDocName = "frm_MainPage" DoCmd.OpenForm stDocName, , , stLinkCriteria DoCmd.Close acForm, "frm_OpenOption", acSaveNo DoCmd.GoToControl , Me.tab_Notes.SetFocus End Sub |
|
#2
|
|||
|
|||
|
I do this without the DoCmd simply:
Me.tab_Notes.SetFocus |
|
#3
|
|||
|
|||
|
Quote:
Hi June7, i did try using that initially but it gives me the same error. Any other thoughts? |
|
#4
|
|||
|
|||
|
Wait, Me.tab_Notes.SetFocus is behind the button on the calling form but tab_Notes is on the called form? Then can't use Me., must refer to the name of form being called: frm_MainPage.tab_Notes.SetFocus
My preferred technique is to have the called form control this (as I was taught). I would use the OpenArgs argument of the OpenForm method to pass criteria to the called form and then in the form Open event extract this criteria and base behavior on this value. So the line in the button Click event would be: DoCmd.OpenForm stDocName, , , stLinkCriteria , , , "Notes" And then in frm_MainForm Open event: If Me.OpenArgs = "Notes" Then Me.tab_Notes.SetFocus Last edited by June7 : October 1st, 2009 at 08:10 PM. |
|
#5
|
|||
|
|||
|
Thanks June7, i finally got it working. You have saved me from absolute madness.
Here is the code for anyone that may have a similar problem in the future. Subform code: Private Sub img_ReportsCorrespondence_Click() Dim stDocName As String Dim stLinkCriteria As String stDocName = "frm_MainPage" DoCmd.OpenForm stDocName, , , stLinkCriteria, , , "Reports" DoCmd.Close acForm, "frm_OpenOption", acSaveNo End Sub MainForm code: If Me.OpenArgs = "Reports" Then Me.tab_Reports.SetFocus Me.cmbo_SelectTeam.SetFocus End If |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Set focus to certain tab on open |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|