473,769 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to SetFocus on an Opened Form?

124 New Member
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_SysMaintenanc e 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 37160
RuralGuy
375 Recognized Expert Contributor
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_Familie s.ControlName.S etFocus
Jan 19 '11 #2
Rabbit
12,516 Recognized Expert Moderator MVP
Or... Just open the form you want focus on last.
Jan 19 '11 #3
bullfrog83
124 New Member
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 Recognized Expert Contributor
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 New Member
Yes, I used my own control name (e.g. Forms!f_Familie s.cboChurch.Set Focus). 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, 808 views)
Jan 20 '11 #6

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

Similar topics

7
7226
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 Sub sbTest() On Error GoTo errHandler Dim frm As Access.Form
8
11341
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 "painted" right on top of the frmUserSettings. Since the Main Menu form is smaller (in width and height) I can click on frmUserSettings and get it to the front (focus). But is there a way to do this programmatically? Can you help me? Here is...
0
1413
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 opens another form based on a SQL view. What is supposed to happen is the search results form opens based on the information entered in one of the controls (Last Name, First Name, Bidder #) Here is the code:
3
17076
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 to overwriting, renaming etc. What is the proper way in windows forms programming to open a new form and wait for the reponse of the form. Currently I open it with form.show(); form.focus(); In the form I have a variable set based on the user's...
1
1207
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 Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
2
10121
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 DoCmd.OpenForm "frmLookupAgencyContactInfo", , , , acFormReadOnly, , strSQL
1
1341
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 log items related to each EquipID. If the user dbl clicks a log item, it opens up a second form, frmLogItems and shows only the log entry they double clicked. No problems here. On the first main form, there is also a command button to enter a new...
6
1710
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 a function in Form B. In example: DelegateAbc^ d = gcnew DelegateAbc(HANDLE,&FormB::TestB);
3
5903
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
2059
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 form has jump button to it's Decision Record form and vice- versa - Project form has jump button to the Needs form for each of its linked 'Needs' The first time you click any jump button the called form comes up and fills the screen. But once...
0
10199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9849
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8861
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7393
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5433
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3948
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3551
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.