By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,856 Members | 1,986 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,856 IT Pros & Developers. It's quick & easy.

Problems bringing focus back to form

P: n/a
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
Share this Question
Share on Google+
13 Replies


P: n/a
Martin,
Some code on the 'On activate'-event will do the trick for you

Private Sub Form_Activate()
Me!Searchbox.setfocus
End sub

--
Hope this helps
Arno R
"Martin Dennett" <md**@ntlworld.com> schreef in bericht
news:ay********************@newsfep2-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

P: n/a
TC
Or, just put the searchbox first in View Tab Order.

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

Private Sub Form_Activate()
Me!Searchbox.setfocus
End sub

--
Hope this helps
Arno R
"Martin Dennett" <md**@ntlworld.com> schreef in bericht
news:ay********************@newsfep2-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

P: n/a
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.tiscal i.nl...
Martin,
Some code on the 'On activate'-event will do the trick for you

Private Sub Form_Activate()
Me!Searchbox.setfocus
End sub

--
Hope this helps
Arno R
"Martin Dennett" <md**@ntlworld.com> schreef in bericht
news:ay********************@newsfep2-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

P: n/a
TC
Yes, good thinking!

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

Private Sub Form_Activate()
Me!Searchbox.setfocus
End sub

--
Hope this helps
Arno R
"Martin Dennett" <md**@ntlworld.com> schreef in bericht
news:ay********************@newsfep2-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

P: n/a
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.tiscal i.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.tiscal i.nl...
> Martin,
> Some code on the 'On activate'-event will do the trick for you
>
> Private Sub Form_Activate()
> Me!Searchbox.setfocus
> End sub
>
> --
> Hope this helps
> Arno R
>
>
> "Martin Dennett" <md**@ntlworld.com> schreef in bericht
> news:ay********************@newsfep2-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

P: n/a
> 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

P: n/a
> (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

P: n/a
> 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.SetWarnings False
DoCmd.RunSQL "DELETE recheckhold.* FROM recheckhold;"

DoCmd.Close acForm, "dc2"
Forms!SWITCHBOARD!OLEUnbound180.Visible = False
Forms!SWITCHBOARD!Text17.Visible = True
Forms!SWITCHBOARD!Text17.SetFocus
Forms!SWITCHBOARD!Text17 = ""
Forms!SWITCHBOARD!Command13.Visible = False
Forms!SWITCHBOARD!Command14.Visible = False
Forms!SWITCHBOARD!Command15.Visible = False
Forms!SWITCHBOARD!Command16.Visible = False
Forms!SWITCHBOARD!Command19.Visible = False
Forms!SWITCHBOARD!Command78.Visible = False
Forms!SWITCHBOARD!Command82.Visible = False
Forms!SWITCHBOARD!Command164.Visible = False
End Sub

The "RunSQL" statement clears the fields in a holding table. "SWITCHBOARD"
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

P: n/a
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!SWITCHBOARD!Text17.SetFocus 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****************@newsfep1-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.SetWarnings False
DoCmd.RunSQL "DELETE recheckhold.* FROM recheckhold;"

DoCmd.Close acForm, "dc2"
Forms!SWITCHBOARD!OLEUnbound180.Visible = False
Forms!SWITCHBOARD!Text17.Visible = True
Forms!SWITCHBOARD!Text17.SetFocus
Forms!SWITCHBOARD!Text17 = ""
Forms!SWITCHBOARD!Command13.Visible = False
Forms!SWITCHBOARD!Command14.Visible = False
Forms!SWITCHBOARD!Command15.Visible = False
Forms!SWITCHBOARD!Command16.Visible = False
Forms!SWITCHBOARD!Command19.Visible = False
Forms!SWITCHBOARD!Command78.Visible = False
Forms!SWITCHBOARD!Command82.Visible = False
Forms!SWITCHBOARD!Command164.Visible = False
End Sub

The "RunSQL" statement clears the fields in a holding table. "SWITCHBOARD"
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

P: n/a
Arno
"Arno R" <ar****************@tiscali.nl> wrote in message
news:3f**********************@dreader2.news.tiscal i.nl...
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!SWITCHBOARD!Text17.SetFocus 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 ...

It's Access 97 - forgot to mention that. I passed on your previous comments
but I've had no feedback yet. I'll pass this over too and let you know how
it goes.

Martin
Nov 12 '05 #11

P: n/a
"Martin Dennett" <md**@ntlworld.com> wrote in message
news:DD***************@newsfep1-gui.server.ntli.net...
It's Access 97 - forgot to mention that. I passed on your previous comments but I've had no feedback yet. I'll pass this over too and let you know how
it goes.


Arno - changes made and still no joy I'm afraid...

MD
Nov 12 '05 #12

P: n/a
Martin,
I would like to see what's happening here.
If you e-mail the mdb I will try to help you out.
Maybe you can 'strip' the mdb and mainly leave the two forms concerned here?
Remove the obvious (n_o_s_p_a_m) from my address.

Arno R.
"Martin Dennett" <md**@ntlworld.com> schreef in bericht
news:iE*************@newsfep1-gui.server.ntli.net...
"Martin Dennett" <md**@ntlworld.com> wrote in message
news:DD***************@newsfep1-gui.server.ntli.net...
It's Access 97 - forgot to mention that. I passed on your previous

comments
but I've had no feedback yet. I'll pass this over too and let you know how
it goes.


Arno - changes made and still no joy I'm afraid...

MD


Nov 12 '05 #13

P: n/a
"Arno R" <ar****************@tiscali.nl> wrote in message
news:3f**********************@dreader2.news.tiscal i.nl...
Martin,
I would like to see what's happening here.
If you e-mail the mdb I will try to help you out.
Maybe you can 'strip' the mdb and mainly leave the two forms concerned here? Remove the obvious (n_o_s_p_a_m) from my address.


The *whole* mdb - all 460Mb of it? :-)

Leave it with me, and I'll send you the forms, modules and a small amount of
data, just so you can see what's going on.

Martin
Nov 12 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.