944,189 Members | Top Members by Rank

Ad:
Nov 3rd, 2006
0

Alter Recordset by Text Box text.

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bogeybrown is offline Offline
7 posts
since Apr 2006
Nov 4th, 2006
0

Re: Alter Recordset by Text Box text.

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
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Nov 8th, 2006
0

Re: Alter Recordset by Text Box text.

Click to Expand / Collapse  Quote originally posted by QVeen72 ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bogeybrown is offline Offline
7 posts
since Apr 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: difficulty creating a formula with a macro
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: how I can know the updates of dllfiles?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC