473,715 Members | 6,043 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems bringing focus back to form

Hi

I'm new to this group so go easy on me!

I currently use a database that has had one constant niggle for a while and
I was wondering if anybody can help sort it out. From an opening screen
there is an option to search for a particular record. The search criteria is
entered into a text box. A form is presented over the top of the opening
screen with the query results and an option is then given for another
search. This results in the open form closing down, but the text box on the
opening screen has to be clicked in to bring the focus back to the search
box. Could somebody please advise how the cursor can be made to flash in the
box immediately the screen is presented, without having to click?

MTIA

MD
Nov 12 '05 #1
13 3220
Martin,
Some code on the 'On activate'-event will do the trick for you

Private Sub Form_Activate()
Me!Searchbox.se tfocus
End sub

--
Hope this helps
Arno R
"Martin Dennett" <md**@ntlworld. com> schreef in bericht
news:ay******** ************@ne wsfep2-win.server.ntli .net...
Hi

I'm new to this group so go easy on me!

I currently use a database that has had one constant niggle for a while and
I was wondering if anybody can help sort it out. From an opening screen
there is an option to search for a particular record. The search criteria is
entered into a text box. A form is presented over the top of the opening
screen with the query results and an option is then given for another
search. This results in the open form closing down, but the text box on the
opening screen has to be clicked in to bring the focus back to the search
box. Could somebody please advise how the cursor can be made to flash in the
box immediately the screen is presented, without having to click?

MTIA

MD

Nov 12 '05 #2
TC
Or, just put the searchbox first in View Tab Order.

TC
"Arno R" <ar************ ****@tiscali.nl > wrote in message
news:3f******** **************@ dreader2.news.t iscali.nl...
Martin,
Some code on the 'On activate'-event will do the trick for you

Private Sub Form_Activate()
Me!Searchbox.se tfocus
End sub

--
Hope this helps
Arno R
"Martin Dennett" <md**@ntlworld. com> schreef in bericht
news:ay******** ************@ne wsfep2-win.server.ntli .net...
Hi

I'm new to this group so go easy on me!

I currently use a database that has had one constant niggle for a while and I was wondering if anybody can help sort it out. From an opening screen
there is an option to search for a particular record. The search criteria is entered into a text box. A form is presented over the top of the opening
screen with the query results and an option is then given for another
search. This results in the open form closing down, but the text box on the opening screen has to be clicked in to bring the focus back to the search box. Could somebody please advise how the cursor can be made to flash in the box immediately the screen is presented, without having to click?

MTIA

MD


Nov 12 '05 #3
Hi TC,
I had a guess that the OP hit Enter or clicked another button to view the results.
Since the form stays open, just taborder won't help I think.

Arno R

"TC" <a@b.c.d> schreef in bericht news:1070257697 .353471@teuthos ...
Or, just put the searchbox first in View Tab Order.

TC
"Arno R" <ar************ ****@tiscali.nl > wrote in message
news:3f******** **************@ dreader2.news.t iscali.nl...
Martin,
Some code on the 'On activate'-event will do the trick for you

Private Sub Form_Activate()
Me!Searchbox.se tfocus
End sub

--
Hope this helps
Arno R
"Martin Dennett" <md**@ntlworld. com> schreef in bericht
news:ay******** ************@ne wsfep2-win.server.ntli .net...
Hi

I'm new to this group so go easy on me!

I currently use a database that has had one constant niggle for a while and I was wondering if anybody can help sort it out. From an opening screen
there is an option to search for a particular record. The search criteria is entered into a text box. A form is presented over the top of the opening
screen with the query results and an option is then given for another
search. This results in the open form closing down, but the text box on the opening screen has to be clicked in to bring the focus back to the search box. Could somebody please advise how the cursor can be made to flash in the box immediately the screen is presented, without having to click?

MTIA

MD





Nov 12 '05 #4
TC
Yes, good thinking!

TC
"Arno R" <ar************ ****@tiscali.nl > wrote in message
news:3f******** **************@ dreader2.news.t iscali.nl...
Hi TC,
I had a guess that the OP hit Enter or clicked another button to view the results. Since the form stays open, just taborder won't help I think.

Arno R

"TC" <a@b.c.d> schreef in bericht news:1070257697 .353471@teuthos ...
Or, just put the searchbox first in View Tab Order.

TC
"Arno R" <ar************ ****@tiscali.nl > wrote in message
news:3f******** **************@ dreader2.news.t iscali.nl...
Martin,
Some code on the 'On activate'-event will do the trick for you

Private Sub Form_Activate()
Me!Searchbox.se tfocus
End sub

--
Hope this helps
Arno R
"Martin Dennett" <md**@ntlworld. com> schreef in bericht
news:ay******** ************@ne wsfep2-win.server.ntli .net...
> Hi
>
> I'm new to this group so go easy on me!
>
> I currently use a database that has had one constant niggle for a while
and
> I was wondering if anybody can help sort it out. From an opening
screen > there is an option to search for a particular record. The search

criteria is
> entered into a text box. A form is presented over the top of the opening > screen with the query results and an option is then given for another > search. This results in the open form closing down, but the text box

on the
> opening screen has to be clicked in to bring the focus back to the

search
> box. Could somebody please advise how the cursor can be made to
flash in the
> box immediately the screen is presented, without having to click?
>
> MTIA
>
> MD
>
>



Nov 12 '05 #5
Unfortunately, the Form_activate () didn't work :-(

I'm not overly familiar with VB so I don't know for sure but the guy who
amends our code said he'd tried it in various places and still drawn a
blank.

MD

"TC" <a@b.c.d> wrote in message news:1070329018 .52910@teuthos. ..
Yes, good thinking!

TC
"Arno R" <ar************ ****@tiscali.nl > wrote in message
news:3f******** **************@ dreader2.news.t iscali.nl...
Hi TC,
I had a guess that the OP hit Enter or clicked another button to view the
results.
Since the form stays open, just taborder won't help I think.

Arno R

"TC" <a@b.c.d> schreef in bericht news:1070257697 .353471@teuthos ...
Or, just put the searchbox first in View Tab Order.

TC
"Arno R" <ar************ ****@tiscali.nl > wrote in message
news:3f******** **************@ dreader2.news.t iscali.nl...
> Martin,
> Some code on the 'On activate'-event will do the trick for you
>
> Private Sub Form_Activate()
> Me!Searchbox.se tfocus
> End sub
>
> --
> Hope this helps
> Arno R
>
>
> "Martin Dennett" <md**@ntlworld. com> schreef in bericht
> news:ay******** ************@ne wsfep2-win.server.ntli .net...
> > Hi
> >
> > I'm new to this group so go easy on me!
> >
> > I currently use a database that has had one constant niggle for a
while and
> > I was wondering if anybody can help sort it out. From an opening screen > > there is an option to search for a particular record. The search
criteria is
> > entered into a text box. A form is presented over the top of the opening > > screen with the query results and an option is then given for another > > search. This results in the open form closing down, but the text
box on the
> > opening screen has to be clicked in to bring the focus back to the
search
> > box. Could somebody please advise how the cursor can be made to flash in the
> > box immediately the screen is presented, without having to click?
> >
> > MTIA
> >
> > MD
> >
> >
>
>



Nov 12 '05 #6
> Unfortunately, the Form_activate () didn't work :-(
I'm not overly familiar with VB so I don't know for sure but the guy who
amends our code said he'd tried it in various places and still drawn a
blank.


The 'guy who amends your code' does only need to try in one place
and that's the Form_Activate event ...
(Why isn't this guy posting himself?)

Check if and when the event is triggered. Put a line like
msgbox "Check on_activate"
as the first line in your code.

What are you doing exactly? Is there a click on a button to show
the "form that is presented over the top of the opening screen"
How is the "option is then given for another search".

An alternative approach:
You could also set the focus back to the desired field BEFORE showing the " form that is ..."

--
Hope this helps
Arno R


Nov 12 '05 #7
> (Why isn't this guy posting himself?)

I said I'd do the dirty work :-)
Check if and when the event is triggered. Put a line like
msgbox "Check on_activate"
as the first line in your code.

What are you doing exactly? Is there a click on a button to show
the "form that is presented over the top of the opening screen"
How is the "option is then given for another search".

An alternative approach:
You could also set the focus back to the desired field BEFORE showing the

" form that is ..."

I'll see if the above works - failing that I'll ask him to mail me the code
and I'll post it here.

MD
Nov 12 '05 #8
> I'll see if the above works - failing that I'll ask him to mail me the
code
and I'll post it here.


OK - I got the code - here it is:

Private Sub Command84_Click ()
DoCmd.SetWarnin gs False
DoCmd.RunSQL "DELETE recheckhold.* FROM recheckhold;"

DoCmd.Close acForm, "dc2"
Forms!SWITCHBOA RD!OLEUnbound18 0.Visible = False
Forms!SWITCHBOA RD!Text17.Visib le = True
Forms!SWITCHBOA RD!Text17.SetFo cus
Forms!SWITCHBOA RD!Text17 = ""
Forms!SWITCHBOA RD!Command13.Vi sible = False
Forms!SWITCHBOA RD!Command14.Vi sible = False
Forms!SWITCHBOA RD!Command15.Vi sible = False
Forms!SWITCHBOA RD!Command16.Vi sible = False
Forms!SWITCHBOA RD!Command19.Vi sible = False
Forms!SWITCHBOA RD!Command78.Vi sible = False
Forms!SWITCHBOA RD!Command82.Vi sible = False
Forms!SWITCHBOA RD!Command164.V isible = False
End Sub

The "RunSQL" statement clears the fields in a holding table. "SWITCHBOAR D"
is the main form that the search criteria is entered on. The information is
displayed on form "dc2". When closing form dc2 to return to SWITCHBOARD
using the "search again" button - that's when the problem occurs. Text17 is
the box that the cursor is not appearing in.

Hope this helps in some way.

MD
Nov 12 '05 #9
Martin,
- This code runs from your form dc2?
Code 'should' work IMO provided that NO OTHER code AFTER this code runs.
Check the code in your Switchboard form especially the On_Activate-event.
- Try moving the line Forms!SWITCHBOA RD!Text17.SetFo cus as the LAST line

- What version of Access ?
- Dis you try all the other options I mentioned?

BTW: I don't see code to SetWarnings True again after the RunSQL; don't forget this ...
--
Hope this helps
Arno R
"Martin Dennett" <md**@ntlworld. com> schreef in bericht
news:GW******** ********@newsfe p1-gui.server.ntli .net...
I'll see if the above works - failing that I'll ask him to mail me the

code
and I'll post it here.


OK - I got the code - here it is:

Private Sub Command84_Click ()
DoCmd.SetWarnin gs False
DoCmd.RunSQL "DELETE recheckhold.* FROM recheckhold;"

DoCmd.Close acForm, "dc2"
Forms!SWITCHBOA RD!OLEUnbound18 0.Visible = False
Forms!SWITCHBOA RD!Text17.Visib le = True
Forms!SWITCHBOA RD!Text17.SetFo cus
Forms!SWITCHBOA RD!Text17 = ""
Forms!SWITCHBOA RD!Command13.Vi sible = False
Forms!SWITCHBOA RD!Command14.Vi sible = False
Forms!SWITCHBOA RD!Command15.Vi sible = False
Forms!SWITCHBOA RD!Command16.Vi sible = False
Forms!SWITCHBOA RD!Command19.Vi sible = False
Forms!SWITCHBOA RD!Command78.Vi sible = False
Forms!SWITCHBOA RD!Command82.Vi sible = False
Forms!SWITCHBOA RD!Command164.V isible = False
End Sub

The "RunSQL" statement clears the fields in a holding table. "SWITCHBOAR D"
is the main form that the search criteria is entered on. The information is
displayed on form "dc2". When closing form dc2 to return to SWITCHBOARD
using the "search again" button - that's when the problem occurs. Text17 is
the box that the cursor is not appearing in.

Hope this helps in some way.

MD

Nov 12 '05 #10

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

Similar topics

1
1830
by: Jens Körte | last post by:
Hi NG! I encountered some strange behaviour when using focus() I use a form with several input-fields. A user can enter stuff. After entering I want to check the value, i.e. that a number is only a number etc. I therefore started editing a Javascript. For test purposes it only popup a message and sets the focus. In fact this is what I want to do, but the scipt isn't it doing right.
17
3855
by: Neil Ginsberg | last post by:
OK, this is a stupid thing, but I can't seem to get this to work. I have a form with a subform (in continuous form view). A combo box on the main form has code in the AfterUpdate event which adds a record to the subform (based on the value of the combo box) and requeries the subform control. I want the focus to return to the combo box on the main form when it's done, but I can't get it to do so if the user enters a value and presses Enter...
7
3309
by: John | last post by:
Hi, I have a group of controls in a panel on the right-hand side of a splitter and a treeview on the left-hand side. The only configuration that I can find to make the right-hand side resize correctly is: lhsTreeview - Dock = Fill, Anchor = Top,Left splitter - Dock = Right rhsPanel - Dock = Right, Anchor = Top,Left
7
1309
by: Martin Hazell | last post by:
I have had a form within a project that has been tested and working for the past 4-5 months. The other day, I decided to change all of my database connection strings into a dynamic property for a few reasons. All was OK until testing a particular form, and I got a strange error when opening it whilst running, and I got an exception stating that the dataset I was using to fill a table was not initialised.
12
7531
by: E Goforth | last post by:
Hello, I have a VB6 app that calls a VB.NET app via named pipes and a third party component. Inside the VB.NET app I'm trying to force a form to the top, at least temporarily. Inside a form's public sub I'm doing: Public Sub ThisIsMySub(TheseAreMyArguments) Me.Show Me.WindowState = FormWindowState.Normal Me.TopMost = True
0
1057
by: Scott Emick | last post by:
I have a main entry screen for a contact manager that has some buttons which can launch various other forms and these launch without any problems. I check if the form already exists and set focus to it, or instantiate it and show it otherwise. The user can flip back and forth by design. The problem comes in when I am trying to launch a script in a form that guides the user through a script that directs him/her step-by-step how to fill...
2
8373
by: Tom | last post by:
I am developing a VB.NET user control that is composed of a component control (along with some classes, etc). This is probably a stupid question, and should be easy, but I must be having a brain fart. In the control itself, how do I set focus BACK to the form that the control is on? This control does some maniuplation of an outside application (by starting up the application and sending it keystrokes). What I want to be able to do is to...
3
2600
by: papalarge | last post by:
I have a VB.NET application that consists of a toolbar and a subwindow that I want to function together and not independently. So when I give focus to one, I want to make sure that the other is visible on the screen (brought to front, right behind the one in focus). I've played with the activated event of each form, but everything I've tried so far fails, as it's a pretty cyclical process that gets initiated. I'd love any help......
5
3491
by: Michel Posseth [MCP] | last post by:
Hello we have encountered the following problems with the date time picker control A : datetime picker control gives focus to last entered field when moving back and forward with focus how do we reset this to the first field ? B : datetime picker in DD-MM-YYYY default format ( europe , NL-NL localization ) refuses an entry of 31 on the DD filed cause the month is already chosen to the current mont ( (02) februari wich only has 28...
0
9340
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
9196
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9103
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7973
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
6646
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
4477
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2539
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2118
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.