Problems bringing focus back to form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin Dennett

    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


  • Arno R

    #2
    Re: Problems bringing focus back to form

    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" <md69@ntlworld. com> schreef in bericht
    news:aynyb.7309 $O42.3294962@ne wsfep2-win.server.ntli .net...[color=blue]
    > 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
    >
    >[/color]


    Comment

    • TC

      #3
      Re: Problems bringing focus back to form

      Or, just put the searchbox first in View Tab Order.

      TC


      "Arno R" <arracomn_o_s_p _a_m@tiscali.nl > wrote in message
      news:3fca0c9a$0 $41747$5fc3050@ dreader2.news.t iscali.nl...[color=blue]
      > 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" <md69@ntlworld. com> schreef in bericht
      > news:aynyb.7309 $O42.3294962@ne wsfep2-win.server.ntli .net...[color=green]
      > > 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[/color][/color]
      and[color=blue][color=green]
      > > 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[/color][/color]
      criteria is[color=blue][color=green]
      > > 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[/color][/color]
      the[color=blue][color=green]
      > > opening screen has to be clicked in to bring the focus back to the[/color][/color]
      search[color=blue][color=green]
      > > box. Could somebody please advise how the cursor can be made to flash in[/color][/color]
      the[color=blue][color=green]
      > > box immediately the screen is presented, without having to click?
      > >
      > > MTIA
      > >
      > > MD
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Arno R

        #4
        Re: Problems bringing focus back to form

        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 ...[color=blue]
        > Or, just put the searchbox first in View Tab Order.
        >
        > TC
        >
        >
        > "Arno R" <arracomn_o_s_p _a_m@tiscali.nl > wrote in message
        > news:3fca0c9a$0 $41747$5fc3050@ dreader2.news.t iscali.nl...[color=green]
        > > 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" <md69@ntlworld. com> schreef in bericht
        > > news:aynyb.7309 $O42.3294962@ne wsfep2-win.server.ntli .net...[color=darkred]
        > > > 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[/color][/color]
        > and[color=green][color=darkred]
        > > > 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[/color][/color]
        > criteria is[color=green][color=darkred]
        > > > 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[/color][/color]
        > the[color=green][color=darkred]
        > > > opening screen has to be clicked in to bring the focus back to the[/color][/color]
        > search[color=green][color=darkred]
        > > > box. Could somebody please advise how the cursor can be made to flash in[/color][/color]
        > the[color=green][color=darkred]
        > > > box immediately the screen is presented, without having to click?
        > > >
        > > > MTIA
        > > >
        > > > MD
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]




        Comment

        • TC

          #5
          Re: Problems bringing focus back to form

          Yes, good thinking!

          TC


          "Arno R" <arracomn_o_s_p _a_m@tiscali.nl > wrote in message
          news:3fcb348b$0 $41757$5fc3050@ dreader2.news.t iscali.nl...[color=blue]
          > Hi TC,
          > I had a guess that the OP hit Enter or clicked another button to view the[/color]
          results.[color=blue]
          > 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 ...[color=green]
          > > Or, just put the searchbox first in View Tab Order.
          > >
          > > TC
          > >
          > >
          > > "Arno R" <arracomn_o_s_p _a_m@tiscali.nl > wrote in message
          > > news:3fca0c9a$0 $41747$5fc3050@ dreader2.news.t iscali.nl...[color=darkred]
          > > > 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" <md69@ntlworld. com> schreef in bericht
          > > > news:aynyb.7309 $O42.3294962@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[/color][/color][/color]
          while[color=blue][color=green]
          > > and[color=darkred]
          > > > > I was wondering if anybody can help sort it out. From an opening[/color][/color][/color]
          screen[color=blue][color=green][color=darkred]
          > > > > there is an option to search for a particular record. The search[/color]
          > > criteria is[color=darkred]
          > > > > entered into a text box. A form is presented over the top of the[/color][/color][/color]
          opening[color=blue][color=green][color=darkred]
          > > > > screen with the query results and an option is then given for[/color][/color][/color]
          another[color=blue][color=green][color=darkred]
          > > > > search. This results in the open form closing down, but the text box[/color][/color][/color]
          on[color=blue][color=green]
          > > the[color=darkred]
          > > > > opening screen has to be clicked in to bring the focus back to the[/color]
          > > search[color=darkred]
          > > > > box. Could somebody please advise how the cursor can be made to[/color][/color][/color]
          flash in[color=blue][color=green]
          > > the[color=darkred]
          > > > > box immediately the screen is presented, without having to click?
          > > > >
          > > > > MTIA
          > > > >
          > > > > MD
          > > > >
          > > > >
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >
          >
          >[/color]


          Comment

          • Martin Dennett

            #6
            Re: Problems bringing focus back to form

            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. ..[color=blue]
            > Yes, good thinking!
            >
            > TC
            >
            >
            > "Arno R" <arracomn_o_s_p _a_m@tiscali.nl > wrote in message
            > news:3fcb348b$0 $41757$5fc3050@ dreader2.news.t iscali.nl...[color=green]
            > > Hi TC,
            > > I had a guess that the OP hit Enter or clicked another button to view[/color][/color]
            the[color=blue]
            > results.[color=green]
            > > 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 ...[color=darkred]
            > > > Or, just put the searchbox first in View Tab Order.
            > > >
            > > > TC
            > > >
            > > >
            > > > "Arno R" <arracomn_o_s_p _a_m@tiscali.nl > wrote in message
            > > > news:3fca0c9a$0 $41747$5fc3050@ 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" <md69@ntlworld. com> schreef in bericht
            > > > > news:aynyb.7309 $O42.3294962@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[/color][/color]
            > while[color=green][color=darkred]
            > > > and
            > > > > > I was wondering if anybody can help sort it out. From an opening[/color][/color]
            > screen[color=green][color=darkred]
            > > > > > 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[/color][/color]
            > opening[color=green][color=darkred]
            > > > > > screen with the query results and an option is then given for[/color][/color]
            > another[color=green][color=darkred]
            > > > > > search. This results in the open form closing down, but the text[/color][/color][/color]
            box[color=blue]
            > on[color=green][color=darkred]
            > > > 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[/color][/color]
            > flash in[color=green][color=darkred]
            > > > the
            > > > > > box immediately the screen is presented, without having to click?
            > > > > >
            > > > > > MTIA
            > > > > >
            > > > > > MD
            > > > > >
            > > > > >
            > > > >
            > > > >
            > > >
            > > >[/color]
            > >
            > >
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Arno R

              #7
              Re: Problems bringing focus back to form

              > Unfortunately, the Form_activate () didn't work :-([color=blue]
              > 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.[/color]

              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




              Comment

              • Martin Dennett

                #8
                Re: Problems bringing focus back to form

                > (Why isn't this guy posting himself?)

                I said I'd do the dirty work :-)
                [color=blue]
                > 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[/color]
                " 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


                Comment

                • Martin Dennett

                  #9
                  Re: Problems bringing focus back to form

                  > I'll see if the above works - failing that I'll ask him to mail me the
                  code[color=blue]
                  > and I'll post it here.[/color]

                  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


                  Comment

                  • Arno R

                    #10
                    Re: Problems bringing focus back to form

                    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" <md69@ntlworld. com> schreef in bericht
                    news:GW6Ab.2593 $AW4.762@newsfe p1-gui.server.ntli .net...[color=blue][color=green]
                    > > I'll see if the above works - failing that I'll ask him to mail me the[/color]
                    > code[color=green]
                    > > and I'll post it here.[/color]
                    >
                    > 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
                    >
                    >[/color]


                    Comment

                    • Martin Dennett

                      #11
                      Re: Problems bringing focus back to form

                      Arno
                      "Arno R" <arracomn_o_s_p _a_m@tiscali.nl > wrote in message
                      news:3fd1ca30$0 $41750$5fc3050@ dreader2.news.t iscali.nl...[color=blue]
                      > 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[/color]
                      On_Activate-event.[color=blue]
                      > - Try moving the line Forms!SWITCHBOA RD!Text17.SetFo cus as the[/color]
                      LAST line[color=blue]
                      >
                      > - 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;[/color]
                      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


                      Comment

                      • Martin Dennett

                        #12
                        Re: Problems bringing focus back to form

                        "Martin Dennett" <md69@ntlworld. com> wrote in message
                        news:DDqAb.367$ J81.140@newsfep 1-gui.server.ntli .net...
                        [color=blue]
                        > It's Access 97 - forgot to mention that. I passed on your previous[/color]
                        comments[color=blue]
                        > but I've had no feedback yet. I'll pass this over too and let you know how
                        > it goes.[/color]

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

                        MD


                        Comment

                        • Arno R

                          #13
                          Re: Problems bringing focus back to form

                          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" <md69@ntlworld. com> schreef in bericht
                          news:iEDAb.61$8 %3.55@newsfep1-gui.server.ntli .net...[color=blue]
                          > "Martin Dennett" <md69@ntlworld. com> wrote in message
                          > news:DDqAb.367$ J81.140@newsfep 1-gui.server.ntli .net...
                          >[color=green]
                          > > It's Access 97 - forgot to mention that. I passed on your previous[/color]
                          > comments[color=green]
                          > > but I've had no feedback yet. I'll pass this over too and let you know how
                          > > it goes.[/color]
                          >
                          > Arno - changes made and still no joy I'm afraid...
                          >
                          > MD
                          >
                          >[/color]



                          Comment

                          • Martin Dennett

                            #14
                            Re: Problems bringing focus back to form

                            "Arno R" <arracomn_o_s_p _a_m@tiscali.nl > wrote in message
                            news:3fd30924$0 $41764$5fc3050@ dreader2.news.t iscali.nl...[color=blue]
                            > 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[/color]
                            here?[color=blue]
                            > Remove the obvious (n_o_s_p_a_m) from my address.[/color]

                            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


                            Comment

                            Working...