Alter Recordset by Text Box text.

Reply

Join Date: Apr 2006
Posts: 7
Reputation: bogeybrown is an unknown quantity at this point 
Solved Threads: 0
bogeybrown bogeybrown is offline Offline
Newbie Poster

Alter Recordset by Text Box text.

 
0
  #1
Nov 3rd, 2006
I get the result I want in a Datagrid by using Recordset Sql:

Select * from MYQUERY Where (name Like 'WHATEVER*')

I change the name by retyping the whole line, substituting the new name,

typed into a long textBox named txt.Select, like this

Private Sub cmdSelect_Click()

Data1.RecordSource = txtSelect.Text
Data1.Refresh

End Sub

When try to use Select * From MYQuery Where ('name Like ' *')
and leave it in the TextBox, putting the next name in the space, nothing happens.

I want to put the names only in the textbox without retyping the whole line of sql to bring up the fields in my query.

Any offers of a few lines of helpful code would be much appreciated.

Bogeybrown
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: Alter Recordset by Text Box text.

 
0
  #2
Nov 4th, 2006
Hi,

Just type the name in TextBox.
and alter the code like this :

Dim TStr as String
TStr = "Select * from MYQUERY Where name Like '*" _
& txtSelect.Text & "*'"
Data1.RecordSource = TStr
Data1.Refresh

Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 7
Reputation: bogeybrown is an unknown quantity at this point 
Solved Threads: 0
bogeybrown bogeybrown is offline Offline
Newbie Poster

Re: Alter Recordset by Text Box text.

 
0
  #3
Nov 8th, 2006
Originally Posted by QVeen72 View Post
Hi,

Just type the name in TextBox.
and alter the code like this :

Dim TStr as String
TStr = "Select * from MYQUERY Where name Like '*" _
& txtSelect.Text & "*'"
Data1.RecordSource = TStr
Data1.Refresh

Regards
Veena

Veena,
Many thanks.
With the addition of a pair of brackets, one before name and the second before the last pair of quote marks, it worked like a charm.

Yours,

Bogeybrown.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC