PDA

Click to See Complete Forum and Search --> : SQL Search in 12 seperate fields


LordCallubonn
Feb 5th, 2000, 11:31 AM
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....

Clunietp
Feb 6th, 2000, 06:04 AM
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

danix
Feb 6th, 2000, 03:38 PM
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