Results 1 to 3 of 3

Thread: [RESOLVED] Need help for search by comboBox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2009
    Location
    India
    Posts
    158

    Resolved [RESOLVED] Need help for search by comboBox

    I have a Access (mdb) file containing fiedls Name, Father, Mother, Regd, Contact i connected with with vb6
    in vb form there is a text1 textbox for search record from above fields and
    to select category to search i put a comboBox (containing list Name, Father, Mother, Regd, Contact)

    I am using this command to search record from field :

    Data1.Refresh
    Data1.RecordSource = "select * from table1 where table1.NAME like '" & Text1.Text & "*'"


    This command search record from name field,
    i want that when combo1 change the field of search from name to Father, mother or ID etc.
    How can i do it, plz create and attach vb example if anybody has
    Thanks in advance.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Need help for search by comboBox

    Something like this? Change Combo1 to whatever your combobox name is.
    Code:
    Data1.RecordSource = "select * from table1 where table1." & Combo1.Text & " like '" & Text1.Text & "*'"
    I am assuming your combobox contains the field names you need
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2009
    Location
    India
    Posts
    158

    Thumbs up Re: Need help for search by comboBox

    Quote Originally Posted by LaVolpe View Post
    Something like this? Change Combo1 to whatever your combobox name is.
    Code:
    Data1.RecordSource = "select * from table1 where table1." & Combo1.Text & " like '" & Text1.Text & "*'"
    I am assuming your combobox contains the field names you need
    THANKS A LOT..... This is the easiest code that i was expected....

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