Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
saidev
Posting Yak Master
101 Posts |
Posted - 2006-08-23 : 20:59:31
|
Hi Guys,I have 3 Drop Down Boxes, 3Dropdown Operators( +, >, <, > =, < =) and 3 Text Boxes.If i select the data from all the 3 drop down boxes and enter the value in all the 3 text boxes for searching it is only taking the last dropdown box value and last text box value for search ignoring the other two dropdowns and text boxes. Here is my code. Can you guys help me what’s wrong. Appreciate your help.Thanks, Me.cboField1.SelectedValue <> "" And Me.cbosearch1.SelectedValue <> "" And Me.txtValue1.Text <> "" Then If Me.cbosearch1.SelectedValue = "=" Then sqlwhere = Me.cboField1.SelectedValue & "='" & Me.txtValue1.Text & "'" ElseIf Me.cbosearch1.SelectedValue = "<" Then sqlwhere = Me.cboField1.SelectedValue & "<'" & Me.txtValue1.Text & "'" ElseIf Me.cbosearch1.SelectedValue = ">" Then sqlwhere = Me.cboField1.SelectedValue & ">'" & Me.txtValue1.Text & "'" ElseIf Me.cbosearch1.SelectedValue = "<= " Then sqlwhere = Me.cboField1.SelectedValue & "<= '" & Me.txtValue1.Text & "'" ElseIf Me.cbosearch1.SelectedValue = ">= " Then sqlwhere = Me.cboField1.SelectedValue & ">='" & Me.txtValue1.Text & "'" End If End If If Me.cboField2.SelectedValue <> "" And Me.cbosearch2.SelectedValue <> "" And Me.txtValue2.Text <> "" Then If Me.cbosearch2.SelectedValue = "=" Then sqlwhere = Me.cboField2.SelectedValue & "='" & Me.txtValue2.Text & "'" ElseIf Me.cbosearch2.SelectedValue = "<" Then sqlwhere = Me.cboField2.SelectedValue & " < '" & Me.txtValue2.Text & "'" ElseIf Me.cbosearch2.SelectedValue = ">" Then sqlwhere = Me.cboField2.SelectedValue & " > '" & Me.txtValue2.Text & "'" ElseIf Me.cbosearch2.SelectedValue = "< =" Then sqlwhere = Me.cboField2.SelectedValue & " <= '" & Me.txtValue2.Text & "'" ElseIf Me.cbosearch2.SelectedValue = "> =" Then sqlwhere = Me.cboField2.SelectedValue & " >= '" & Me.txtValue2.Text & "'" End If End IfIf Me.cboField3.SelectedValue <> "" And Me.cbosearch3.SelectedValue <> "" And Me.txtValue3.Text <> "" Then If Me.cbosearch3.SelectedValue = "=" Then sqlwhere = Me.cboField3.SelectedValue & " = '" & Me.txtValue3.Text & "'" ElseIf Me.cbosearch3.SelectedValue = "<" Then sqlwhere = Me.cboField3.SelectedValue & " < '" & Me.txtValue3.Text & "'" ElseIf Me.cbosearch3.SelectedValue = ">" Then sqlwhere = Me.cboField3.SelectedValue & " > '" & Me.txtValue3.Text & "'" ElseIf Me.cbosearch3.SelectedValue = "< =" Then sqlwhere = Me.cboField3.SelectedValue & " <= '" & Me.txtValue3.Text & "'" ElseIf Me.cbosearch3.SelectedValue = "> =" Then sqlwhere = Me.cboField3.SelectedValue & " >= '" & Me.txtValue3.Text & "'" End If End If Dim dbFunctions As New DatabaseUtilities Me.initDataGrid(sql & sqlwhere) |
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2006-08-23 : 21:09:52
|
Have you tried debugging this at all???Your code does not concatenate the sqlWhere parameter it simply replaces it.Try using sqlWhere = sqlWhere + _______You should have a decent shot at debugging your own stuff because people are less likely to help when you haven't tried helping yourself. |
 |
|
|
|
|