Results 1 to 4 of 4

Thread: user defined selection criteria form / SQL

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    3

    Thumbs up

    Hi
    I wish to give Users the option of searching a database for a particular record(s) (OK, tuples as it is relational) based on the User's own search criteria. If there isn't anything out there I may write it myself and post it here.

    What I want to be able to do is to provide a form with a combobox control which lists all the field (Column) names and allows the user to select from this (unlimited - well quite a few - criteria would be allowed). There are also two txtboxes next to this for providing either a single search value or range of values. A few checkboxes are also provided to select (and / or / not). A List or txtbox also shows the selection criteria as it is built (the text should also be editable). A final control would be necessary to either save / run the query.

  2. #2
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ....

    You are certainly looking for a headache.

    Well, let's take a simple case and you can enhance it to suit your needs.

    In your database, you have 3 fields named 'FirstName', 'LastName' and 'Age'. You have a combo on your form to display these field names. You also have a textbox to accept the criterion from the user.

    The functionality of the code is to search for the user-entered value in the selected column. The code will look like this:

    Code:
    strQueryString = "Select * from <table name> where "
    strQueryString = strQueryString & Combo1.text
    strQueryString = strQueryString & " = '"
    strQueryString = strQueryString & Text1.Text & "'"
    Suppose the user selects 'FirstName' in the combo and enters 'honeybee' in the textbox, the strQueryString will look like:

    Select * from <table name> where FirstName = 'honeybee'\

    For numeric fields, you have to put validations and conversion routines. If you decide to have the and/or functionality as well, you have added tasks on your list. If this example satisfies you, you can discuss it in more details with me either on the forum or through mail.

    Hope it helps...

    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    3

    Talking

    Thanks for the input; but I already know HOW to do it; I just had hoped that someone had already tried it because I am a just TOO lazy!!

    I'll do it now and post it here.

    Thanks again.

    Wayne

  4. #4
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Oh God!

    s_prog, it's nice when someone serves you food. But sometimes you just have to do it yourself.

    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

Posting Permissions

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



Click Here to Expand Forum to Full Width