473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to SetFocus on an Opened Form?

124 100+
I have a login form. If a user enters the correct username and password I want to open certain forms and close the login form (among other things) when the Sign In button is clicked. I have this code in the cmdSignIn_Click() event:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "f_Families"
  2. DoCmd.OpenForm "f_GiftProcessing"
  3. DoCmd.OpenForm "f_Reports"
  4. DoCmd.OpenForm "f_SysMaintenance"
  5. DoCmd.Close acForm, "f_Login"
  6.  
However, what I want to have happen is after the login form is closed I want to set the focus to the f_Families form, the first form that was opened. Right now, the focus goes to the f_SysMaintenance form. I've tried adding a line of code after I close f_Login using all these different variations but none work:

Expand|Select|Wrap|Line Numbers
  1. Forms!f_Families.SetFocus
  2. Forms!f_Families.Form.SetFocus
  3. DoCmd.SelectObject acForm, "f_Families"
  4.  
You'd think this would be a simple task but no matter what I try, the focus always goes to the last form opened in my code. How do I do this? Thanks!
Jan 19 '11 #1
5 36965
RuralGuy
375 Expert 256MB
Set your focus to a control on the form you want to have the focus. I'm surprised you want so many forms open at once.
Forms!f_Families.ControlName.SetFocus
Jan 19 '11 #2
Rabbit
12,516 Expert Mod 8TB
Or... Just open the form you want focus on last.
Jan 19 '11 #3
bullfrog83
124 100+
That doesn't work. The reason I want so many forms open is because I have my forms open as tabbed documents with the documents tab displayed so when the user logs in, he can easily tab between the four main forms now open. I could open my f_Families form last (and I thought of that) but I want the tabs to be in a specific order. Is there another way to get at what I want?
Jan 19 '11 #4
RuralGuy
375 Expert 256MB
You are saying that the SetFocus code I supplied does *not* work? You used your ControlName, right? Something else is going on. Can you post your db, or at least enough of a sample so that we can test this?
Jan 19 '11 #5
bullfrog83
124 100+
Yes, I used my own control name (e.g. Forms!f_Families.cboChurch.SetFocus). I've attached my db. Again, the code is triggered on the OnClick event of the Sign In command button on my f_Login form. To test the code, use these credentials on the login form:

username = michele
password = shelly

She is the only user set up.

Thanks!
Attached Files
File Type: zip Open Form Test.zip (845.4 KB, 804 views)
Jan 20 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: a s i l b a . p t | last post by:
Can someone please explain why the following code raises error 2450?... Note: frmTest is a simple form with code behind form so it can be instantiated through the form's class module. Public...
8
by: Susan Bricker | last post by:
Hi. I am opening a form (frmUserSettings) just before (or so I thought) the Main Menu form (frmMainMenu) is opening but it's not getting the focus. It gets "painted" and then the Main Menu gets...
0
by: Mike | last post by:
I have a form that has a search button on it. The form has three text boxes, last name, first name, and bidder number. I put in a last name and click the search button. Clicking the search button...
3
by: HooHa | last post by:
I am writing a program that has a portion which downloads files into a selected directory. It first checks to see if the file exists if the file exists it opens another form with buttons related...
1
by: anthony | last post by:
Hi, I have a button (Button1) to open the main form. If I want to have another button to close this opened form, how do I do it without making Mainform a global variable? Thanks! Private...
2
by: bobh | last post by:
Hi All, In AccessXP on the main menu screen I give the user the option to open this form in either Edit or Read-Only mode. When the user chooses read-only which I use the following line ...
1
by: Jimmy | last post by:
I know I've done this before but I can't find where I did it or remember exactly how. The situation is this: There is a form of equipment with primary key EquipID. There a continuous subform of...
6
by: =?Utf-8?B?VG9tYXM=?= | last post by:
Hi, I have an C++/CLI MDI application with two Forms A and B. When I work with Form A I would like to know the handle of Form B (if it is opened), to use its handle in a delegate that execute...
3
by: questionit | last post by:
Hi All How to bring an already opened form in front of all other forms ? Anyone with any ideas please? Thanks Qi
1
by: Denise | last post by:
I have several big forms that are Maximized on Load. I have "Jump" buttons on each to flip to other related forms. - 'Needs' form has jump button to it's linked Project, if it is linked - Project...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.