473,529 Members | 3,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SetFocus to a form

I have a bunch of hidden, popup, non-modal forms.
Forms(myFormName).SetFocus makes myFormName visible.

However...

I have a bunch of non-hidden, popup, non-modal forms.
Forms(myFormName).SetFocus does not bring frmFormName to the front.

How can this be done?

lq

Nov 13 '05 #1
3 2855
On 16 Oct 2005 21:11:24 -0700, "Lauren Quantrell"
<la*************@hotmail.com> wrote:
I have a bunch of hidden, popup, non-modal forms.
Forms(myFormName).SetFocus makes myFormName visible.

However...

I have a bunch of non-hidden, popup, non-modal forms.
Forms(myFormName).SetFocus does not bring frmFormName to the front.

How can this be done?


Hide 'em first?

mike
Nov 13 '05 #2
I found the solution:

Private Declare Function apiSetForegroundWindow Lib "user32" Alias
"SetForegroundWindow" _
(ByVal hWnd As Long) As Long

Function BringFormToFront(F As Form)
On Error Resume Next
' bring a form to the front
Call apiSetForegroundWindow(F.hWnd)
End Function

Nov 13 '05 #3
The Function BringFormToFront works fine, except that was not the
problem.

Problem was I was clicking on a combo box of form names on another
form, so the focus was not leaving that form. When I moved the
....SetFocus code from the form to a code module it works fine.

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
10171
by: Corepaul | last post by:
I am a newbie using Access 2000. I am using the following test in the txtAlbum OnExit procedure to prevent leaving an empty text box for a required field If (IsNull(txtAlbum.Value)) Or (Len(txtAlbum.Value) < 1) Then MsgBox("Album Title cannot be empty") txtAlbum.SetFocus End If
4
9668
by: Mad Scientist Jr | last post by:
i am trying to set focus to a specific control depending on the outcome of a validator control and it is not working. none of these methods are working to setfocus: 1. RegisterStartupScript("sf","<scriptlanguage='javascript'>document.form.MyControlID.focus();</script>"); 2. Andy Smith's FirstFocus control from...
7
1829
by: jaYPee | last post by:
i have a tabcontrol in my form and i have a datagrid in tab2 and want to validate the data in tab1 before the user can encode data in datagrid. i set the the datagrid1_enter event to something like this: Private Sub DataGrid1_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Enter If IDNo.Text = "" Then...
3
6657
by: Jim Devenish | last post by:
In my application vehicles arrive and depart from a workshop. The ArrivalDate and the HandoverDate are each entered. Sometimes the person who should enter the arrival date forgets to do so. When the vehicle is handed over to the customer and the HandoverDate is entered I wish to warn about the possibly missing ArrivalDate. In the...
1
2020
by: fonzie | last post by:
I a form with tab control will all fields based on one table. I have some code setup for the 'On Change' event of the tab control that checks to see if a field on the main form is null. If it is, I want the focus set back to that field on the main form, but I can't get the code to change the focus to anything off of the tab page. This is...
12
2863
by: Michael R | last post by:
TabCtrl --- ..............Tab1--Subform1 ..............Tab2--Subform2---TabCtrl2---Tab21 ..........................................................---Tab22 ..........................................................---Tab23 ..............Tab3--Subofrm3 I need to setfocus on Tab22 I've tryed - me.Tab2.Tab22.setfocus and...
5
3264
agroover
by: agroover | last post by:
I can't seem to figure out how to get rid of the errors. I recieve the following error when I leave the Grade.SetFocus in my code... Microsoft Access can't move the focus to the control Grade GRADE.SetFocus - Highlighted when I hit debug on the error message Private Sub C_Click()
8
9753
by: OldBirdman | last post by:
This should be so, so simple I hesitate to ask. I have a Form named "fNavButtons" used as a SubForm in control named "subformNavButtons". subformNavButtons is a control on my main form named "fAAA". fNavButtons has 2 CommandButtons, cmdNextRec and cmdPrevRec. These are on a subform to allow an AutoRepeat to continue when form fAAA gets...
1
2045
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' ...
3
16931
by: ckrows | last post by:
I have a main form with a button that makes a subform visible. I added a button in the form footer of the subform that is supposed to hide the subform. This does not work because the focus is on that form. I tried moving the focus back to the main form and it fails because it says it does not recongize the entered form. I tried a docmd.close...
0
7353
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7277
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7516
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. ...
0
7626
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...
0
5814
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...
1
5204
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...
0
3339
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1732
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
0
568
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...

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.