In Access, can cursor default to the search box on a form?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DanicaDear
    Contributor
    • Sep 2009
    • 269

    In Access, can cursor default to the search box on a form?

    Is it possible to have the cursor default to the Search box on an Access form when the form is opened? I have several forms that are used for both data entry and viewing. We use the search box a LOT. If someone types something to search, forgetting to put the cursor in the search box, they end up typing over data somewhere.

    Would be awesome to put the cursor in the search box on FormOpen...but I haven't found out how, or if it's even possible.

    Anyone?

    Thank you smart people! :-)
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32656

    #2
    Rushed - but :
    Code:
    Call Me.{ControlName}.SetFocus()
    should be all you need.

    Comment

    • DanicaDear
      Contributor
      • Sep 2009
      • 269

      #3
      But it's not my control...it's the Access built-in search box in the navigation bar (I think it's called navigation bar...by the forward and backward arrows at the bottom of the application.)

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32656

        #4
        Actually, now I have a little more time, there are a couple of ways.
        1. If you set the tab order such that the Control you want to go to first is first (.TabStop=True & .TabIndex=0) then it will start there automatically. This is often all that's required.
        2. Otherwise, in either the Form_Open() or Form_Load() event procedures include the line from my earlier post.
          So, if your Control is called {ControlName} then you'd use :
          Code:
          Call Me.{ControlName}.SetFocus()

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32656

          #5
          Originally posted by DanicaDear
          DanicaDear:
          I think it's called navigation bar...by the forward and backward arrows at the bottom of the application.
          Are you talking about the part of the form at the bottom which is enabled by setting .NavigationButt ons to Yes? Sometimes looking like :
          [IMGNOTHUMB]https://bytes.com/attachment.php? attachmentid=98 46&stc=1&d=1547 511958[/IMGNOTHUMB]
          I wouldn't describe this as a search box so much as a navigation bar. You can go backwards and forwards using the buttons but you can only enter the positional record number in that box to select a record.

          If that is what you mean then I know of no way to navigate to that box I'm afraid.
          Attached Files
          Last edited by NeoPa; Jan 15 '19, 12:29 AM.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32656

            #6
            PS. I just noticed we're both coming up to a count of posts that is a ppower of two. You'll probably get to 256 (2^8) before I reach 32,768 (2^15) :-(
            Did I mention it's always fun to see your posts :-)

            Comment

            • twinnyfo
              Recognized Expert Moderator Specialist
              • Nov 2011
              • 3662

              #7
              There is also a search box in the Navigation Control, but I’ve never tried to set focus on it programmaticall y. I’ve never even thought to try.

              I’ll try to take a look at this....

              Comment

              • DanicaDear
                Contributor
                • Sep 2009
                • 269

                #8
                twinnyfo is winning!
                Yes, that's what I'm trying to do. :-)
                It would be crazy awesome in a number of programs I've written.

                NeoPa, thank you, it's always fun getting the answers I need. LOL!!

                Comment

                • twinnyfo
                  Recognized Expert Moderator Specialist
                  • Nov 2011
                  • 3662

                  #9
                  As I've looked at it, the only thing one can do with the NavigationButto ns is set its value to True or False (shown or unshown).

                  Even though when one clicks into that section, one can tab through the controls (including the little search box), I have found no way to "jump to it" from the Form itself.

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32656

                    #10
                    Originally posted by TwinnyFo
                    TwinnyFo:
                    There is also a search box in the Navigation Control
                    How about a picture. You've lost me on this one.

                    Comment

                    • twinnyfo
                      Recognized Expert Moderator Specialist
                      • Nov 2011
                      • 3662

                      #11
                      Certainly! Here it is:

                      [imgnothumb]https://bytes.com/attachment.php? attachmentid=98 48&stc=1&d=1547 637971[/imgnothumb]
                      Attached Files

                      Comment

                      • DanicaDear
                        Contributor
                        • Sep 2009
                        • 269

                        #12
                        twinnyfo and NeoPa, thank you so much for your time! I tried to figure this out several years ago and no luck then either. :-)

                        Comment

                        • twinnyfo
                          Recognized Expert Moderator Specialist
                          • Nov 2011
                          • 3662

                          #13
                          And you have now officially submitted 2^8 posts on Bytes!

                          Comment

                          • Rabbit
                            Recognized Expert MVP
                            • Jan 2007
                            • 12517

                            #14
                            An alternative could be to replicate the functionality with your own set of form controls

                            Comment

                            • NeoPa
                              Recognized Expert Moderator MVP
                              • Oct 2006
                              • 32656

                              #15
                              I found it when I looked at one of my 2010 databases. Most of my work is still in 2003 as that's what my main client uses.

                              Comment

                              Working...