Search Number Two

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

    #1

    Search Number Two

    OK folks I am having a serious brain fart here and can't get the code
    to do what I really want done. I have a form that has a multi-table
    query as its data source. The data is dsplayed on the form as a
    series of text boxes and combo boxes. I want to have a button that
    when clicked will search the previous control (as long as it is one of
    the text boxes or combo boxes that contain data) for the text the user
    requests. The search should only be performed on the data displayed
    in the given previous control. If the previous control is a text box,
    the serach should look for the requested text in the bound field. If
    the previpous control is a combo box, the serach should look for the
    requested text in the field displayed in the combo box, hoever I dont
    want it to serach the available values in the combo box, I want it to
    search the records for any who have the selected valeu containing the
    search text. If it would help any I can put a hidden text box with
    the displayed data element of the combo box somewhere on the form.
    Anyone want to take a stab at this?

    Thanks...

  • Smartin

    #2
    Re: Search Number Two

    DavidB wrote:
    OK folks I am having a serious brain fart here and can't get the code
    to do what I really want done. I have a form that has a multi-table
    query as its data source. The data is dsplayed on the form as a
    series of text boxes and combo boxes. I want to have a button that
    when clicked will search the previous control (as long as it is one of
    the text boxes or combo boxes that contain data) for the text the user
    requests. The search should only be performed on the data displayed
    in the given previous control. If the previous control is a text box,
    the serach should look for the requested text in the bound field. If
    the previpous control is a combo box, the serach should look for the
    requested text in the field displayed in the combo box, hoever I dont
    want it to serach the available values in the combo box, I want it to
    search the records for any who have the selected valeu containing the
    search text. If it would help any I can put a hidden text box with
    the displayed data element of the combo box somewhere on the form.
    Anyone want to take a stab at this?
    >
    Thanks...
    >
    So, let me see if I understand this... you want to know what control the
    user previously hit before clicking the command button, and base a query
    off that?

    This could be fun, if your a bit masochistic (^:

    Off the top of my head, this sounds like a fun code project. Create a
    global variant in the form's code module to store a control's value.
    Next in each of the subject controls you will need to write code in the
    Lost_Focus event that stores the value of the control that was exited.

    When the button fires, code must build a query to execute on the fly
    using the stored value. Since the input type can vary (alpha, numeric,
    or Null) you will probably need to build some decision making to create
    the query syntax appropriately.

    Note also, someone might hit the button without having exited a subject
    control, and you will need to account for this also.

    Having said all that, this seems an awkward and unintuitive way (from a
    user's perspective) to build a query. What's behind this?

    --
    Smartin

    Comment

    • Rick Brandt

      #3
      Re: Search Number Two

      Smartin wrote:
      So, let me see if I understand this... you want to know what control
      the user previously hit before clicking the command button, and base
      a query off that?
      >
      This could be fun, if your a bit masochistic (^:
      >
      Off the top of my head, this sounds like a fun code project. Create a
      global variant in the form's code module to store a control's value.
      Next in each of the subject controls you will need to write code in
      the Lost_Focus event that stores the value of the control that was
      exited.
      Or the button's code could just use...

      Screen.Previous Control

      --
      Rick Brandt, Microsoft Access MVP
      Email (as appropriate) to...
      RBrandt at Hunter dot com


      Comment

      • Swans, What Swans?

        #4
        Re: Search Number Two

        In article <m6NCh.46950$Gr 2.30589@newssvr 21.news.prodigy .net>,
        rickbrandt2@hot mail.com says...
        Smartin wrote:
        So, let me see if I understand this... you want to know what control
        the user previously hit before clicking the command button, and base
        a query off that?

        This could be fun, if your a bit masochistic (^:

        Off the top of my head, this sounds like a fun code project. Create a
        global variant in the form's code module to store a control's value.
        Next in each of the subject controls you will need to write code in
        the Lost_Focus event that stores the value of the control that was
        exited.
        >
        Or the button's code could just use...
        >
        Screen.Previous Control
        >
        >
        I know how to use previuoscontrol and in fact my object naming
        convention is such that it is easy for me to determine if the previous
        control was a text box, combo box, or other object. Other objects would
        give the user a message to pick an appropriate field to search on. That
        all I have down. What I dont know how to do is simulate the search
        functionality of the built in search in access. the find, find next,
        etc AND how to do that not only on a text box on the calling form but
        also on a combo box (searching on the displayed value rather than the
        stored value.

        Comment

        • Jana

          #5
          Re: Search Number Two

          On Feb 20, 9:03 pm, Swans, What Swans? <f...@barkingpu mpkin.ooo>
          wrote:
          In article <m6NCh.46950$Gr 2.30...@newssvr 21.news.prodigy .net>,
          rickbran...@hot mail.com says...
          >
          >
          >
          >
          >
          Smartin wrote:
          So, let me see if I understand this... you want to know what control
          the user previously hit before clicking the command button, and base
          a query off that?
          >
          This could be fun, if your a bit masochistic (^:
          >
          Off the top of my head, this sounds like a fun code project. Create a
          global variant in the form's code module to store a control's value.
          Next in each of the subject controls you will need to write code in
          the Lost_Focus event that stores the value of the control that was
          exited.
          >
          Or the button's code could just use...
          >
          Screen.Previous Control
          >
          I know how to use previuoscontrol and in fact my object naming
          convention is such that it is easy for me to determine if the previous
          control was a text box, combo box, or other object. Other objects would
          give the user a message to pick an appropriate field to search on. That
          all I have down. What I dont know how to do is simulate the search
          functionality of the built in search in access. the find, find next,
          etc AND how to do that not only on a text box on the calling form but
          also on a combo box (searching on the displayed value rather than the
          stored value.- Hide quoted text -
          >
          - Show quoted text -
          David:

          Take a look at the FindRecord Action in help for dealing with
          searching for records. Note that the field you're going to search in
          has to have the focus. Combo boxes are only searchable on the stored
          value as far as I know, though you can get what the displayed text of
          a combo box is by using the Column property of your combo box if you
          want to search some other text field for the displayed text. The
          counting of columns is zero based, so column 1 is really 0 and column
          2 is 1. So, if you wanted to grab the displayed text of a 2 column
          combo box and the first column is your bound column and the second
          column is the displayed text, you'd use something like this in your
          code:
          stMyDisplayedTe xt = Me.MyComboBoxNa me.Column(1)

          HTH,
          Jana

          Comment

          Working...