Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 30th, 2009, 12:43 AM
Daniel Shiel Daniel Shiel is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Posts: 19 Daniel Shiel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 58 m 56 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old September 30th, 2009, 03:41 PM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 536 June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 13 h 58 m 7 sec
Reputation Power: 124
I do this without the DoCmd simply:
Me.tab_Notes.SetFocus

Reply With Quote
  #3  
Old September 30th, 2009, 06:24 PM
Daniel Shiel Daniel Shiel is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Posts: 19 Daniel Shiel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 58 m 56 sec
Reputation Power: 0
Quote:
Originally Posted by June7
I do this without the DoCmd simply:
Me.tab_Notes.SetFocus


Hi June7, i did try using that initially but it gives me the same error.

Any other thoughts?

Reply With Quote
  #4  
Old October 1st, 2009, 08:07 PM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 536 June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 13 h 58 m 7 sec
Reputation Power: 124
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
Comments on this post
micky agrees!
Daniel Shiel agrees: Very helpful.

Last edited by June7 : October 1st, 2009 at 08:10 PM.

Reply With Quote
  #5  
Old October 1st, 2009, 10:50 PM
Daniel Shiel Daniel Shiel is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Posts: 19 Daniel Shiel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 58 m 56 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Set focus to certain tab on open


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek