Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Aug 2001
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    search shows original form (97/sr1)

    How do I use an already created unbound search box, which is attached to a query, to pull up the original form that the record was created with, instead of showing it in datasheet view? I want to user to be able to perform the search using a search box, and have the original form/s appear, depending on what the user was searching on.

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: search shows original form (97/sr1)

    I'm not sure I understand what you mean by an unbound search box. Is it a drop-down combo box that is unbound, and you have a rowsource for the combo box that gives you a unique key for each record? If that's what you are dealing with then you can use the combo box wizard and have it create code that will display the data record based on the choice you make in the combo box. Does that help?
    Wendell

  3. #3
    New Lounger
    Join Date
    Aug 2001
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: search shows original form (97/sr1)

    Oops. Sorry for not being more specific. I created a form that acts as a search mechanism. There are currently 6 unbound text boxes on the form. I can use these boxes to enter in my search info. I then click the OK button, which is then bound to a search query. When the query completes, it shows it in a datasheet view. What I would like to do, is use this search form, enter in the search info, click OK and then have that Onclick event proc. go out and pull up the original form that was created that matches the search info.

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: search shows original form (97/sr1)

    Ah - now I think I understand. I presume the criteria in your query looks something like
    FieldXX = forms![MyForm]![MyComboBox1] and FieldYY = forms![MyForm]![MyComboBox2] AND ....
    Or are you constructing SQL on the fly?
    The latter let's you ignore combo boxes that are empty (no selection), so it's a bit more flexible.

    ________________________________
    I then click the OK button, which is then bound to a search query.

    You can't bind a button to a query, so I'm not sure you mean, but I suspect you are actually doing a Docmd.OpenQuery or something like that. If you want a form to open, you can bind your form to the search query and execute a DoCmd.OpenForm. Or you can create the SQL statement for your form RecordSource on the fly in the OnOpen event of the form. Yet another alternative is to create a filter statement in code based on the selections in the search form, and then apply the filter. Lots of ways to skin the cat - the more flexible ones involve writing some VBA and some SQL statements. Hope this helps.
    Wendell

  5. #5
    New Lounger
    Join Date
    Aug 2001
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: search shows original form (97/sr1)

    I have an OnClick event when I click on the search button. It is a DoCmd.OpenQuery. When I click on the "Search" button, it runs the Search query and finds results depending on what I've entered into the unbound text boxes. When the query find's it's results, it shows the results in a datasheet view. After the user views the datasheet results and finds the item in need, what would be really cool is if the user could click on the desired item, using that same results datasheet and have it open up the form that was used to create that item. Or fill a new form with all the field information to make it appear like it was the original form. Any ideas on how to do this?

  6. #6
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    632
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: search shows original form (97/sr1)

    Wendell alluded to building SQL on the fly. If you are at all comfortable doing *that*, here's a scenario that would accomplish your goal:

    - use your search form as you are doing currently
    - OnClick search button -- build the SQL statement
    - open the form (NOT the query) in datasheet mode, using the dynamic SQL statement as the "OpenArgs" of the OpenForm statement
    - in the OnOpen event of the form, use the OpenArgs property of the form to dynamically set the recordsource of the form according to the SQL statement that you built previously.

    This would display the records in a datasheet for your users to select the record of interest. Once they've done that, they switch the form into form view. Two methods I've used for doing that: 1) train them to right-click on the form's title bar and choose "Form view", or 2) create a custom menu bar with "Form View" and "Datasheet View" buttons.

    Using this method presumes you are comfortable with building SQL on the fly.



    Hope this helps.
    --------------------------------------------------
    Jack MacDonald
    Vancouver, Canada

  7. #7
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: search shows original form (97/sr1)

    Sorry for not responding sooner, but it looks like Jack as pretty much hit the nail on the head. One question reamains in my mind however. Is it your intention to display more data in the form view than you are displaying in the query datasheet? If not, then why not just display the records in a form and let the user step through them till they find the desired record. That does mean that the user would have to be comfortable with using the navigation controls on a form. Just a thought.
    Wendell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •