Results 1 to 3 of 3

Thread: SQL Search in 12 seperate fields

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 1999
    Location
    Corry,PA, USA
    Posts
    15

    Post

    I am in the middle of making a Daily Production Report DB for my business & I have setup my db to record the daily output for each shift
    I have setup 1 table & 150 fields within it to make the job abit easier. I need to do a part number search so my data control will place the searched for data into a dbgrid..
    I've tried many ways & many places to find a multi-field search SQL cod ethat will work the way I need it..

    I've tried the following code to no avail:

    Private Sub Command1_Click()
    grid.Data1.RecordSource = "SELECT Info.PartNumber1, Info.PartNumber2, Info.PartNumber3, Info.PartNumber4, Info.PartNumber5, Info.PartNumber6, Info.PartNumber7, Info.PartNumber8, Info.PartNumber9, Info.PartNumber10, Info.PartNumber11, Info.PartNumber12 From Info where Info.PartNumber1, Info.PartNumber2, Info.PartNumber3, Info.PartNumber4, Info.PartNumber5, Info.PartNumber6, Info.PartNumber7, Info.PartNumber8, Info.PartNumber9, Info.PartNumber10, Info.PartNumber11, Info.PartNumber12 = '" & txtTargetName.Text & "'"

    grid.Data1.Refresh

    Unload Me
    End Sub

    '
    I am using a extbox for user input, if anyone would happen to know how I can help me fix this SQL delema I would be most apreciated.. Thank you..

    ------------------
    ~\*/~ Thank you....

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    A few things here:

    1) you want to set the data1.recordsource to your SQL statement, not Grid.data1.recordsource

    2) Based on your table, your sql will have to be something like:
    "Select * from MyTable where Part1 = '" & text1.text & "' OR Part2 = '" & text1.text & "' OR ".......................

    3) The reason your query is so complex is because your table is probably not properly normalized, but that's another topic.

    HTH

    Tom

  3. #3
    Junior Member
    Join Date
    Jan 2000
    Location
    uk
    Posts
    20

    Post

    Remeber that in your sql statement you must put the correct brackets when using multiple OR statements in sql ie
    SELECT * FROM atable WHERE (something = ? OR something = ? OR something = ? OR something = ?) etc

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