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 |
|
JezLisle
Posting Yak Master
132 Posts |
Posted - 2008-11-10 : 08:37:37
|
| I have a form which has a ComboBox, TextBox & ListBox.On Open the ListBox is populated with data. in the ComboBox I have the fields the user can search from. The TextBox is used for the Search criteria.How can I change this code below into SQL Statement so that I can load it from a Stored Procedure?"SELECT * FROM jez_SWM_FindNHSNo " & _ "WHERE jez_SWM_FindNHSNo." + Me.cboSearchOn + " LIKE '" & Me.txtInputSearch.Text & "%' " & _ "ORDER BY jez_SWM_FindNHSNo.Surname, jez_SWM_FindNHSNo.Forename" |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2008-11-10 : 08:41:52
|
| SELECT * FROM jez_SWM_FindNHSNo WHERE jez_SWM_FindNHSNo.<YOURFIELDNAME> LIKE '<TXTINPUTSEARCH>%' ORDER BY jez_SWM_FindNHSNo.Surname, jez_SWM_FindNHSNo.Forename |
 |
|
|
JezLisle
Posting Yak Master
132 Posts |
Posted - 2008-11-10 : 08:55:25
|
| Excellent Thanks, so in the EXEC Statement, how do I make the TextBox input fit to the <TXTINPUTSEARCH> field? also, the <YOURFIELDNAME> would differ from eith NHS Number, Surname or Forename how would that be picked up? |
 |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2008-11-10 : 09:30:04
|
| You can use dynamic sql to make the statement. Look for dynamic sql in knowledge docs. You'll find a lot in this forum too. |
 |
|
|
|
|
|