954,124 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Alter Recordset by Text Box text.

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

bogeybrown
Newbie Poster
7 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

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

QVeen72
Posting Shark
950 posts since Nov 2006
Reputation Points: 84
Solved Threads: 143
 

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.

bogeybrown
Newbie Poster
7 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You