"Me.RecordSource = strSQL" excludes everything, but I don't see why

P

plh

Hello Everyone,
MS Office Access 2003 SP2
I have a form in the continuous form type of view. On the form header is a text
box for users to filter the field 'COP' accordingly. COP is the customer order
number. So for example, if they type in "1" <Enter> they should see only the
records that begin with 1, if they add "2" <Enter> so that it says "12", they
should see only those records that begin with "12", etc. Here is my code:
Private Sub txtFilter_AfterUpdate()

Dim strSQL As String

strSQL = "SELECT * FROM tblCustOrds WHERE COP LIKE '" & Me.txtFilter.Value &
"%'"

Me.RecordSource = strSQL

End Sub

I can look in the property window at the form's RecordSource property and see
that it is now (with txtFilter containing a "1"):

SELECT * FROM tblCustOrds WHERE COP LIKE '1%'
(That is a direct Copy/Paste)

The problem is that the form is excluding everything, no matter what is in the
text box. There are plenty of COPs that begin with "1"
What am I doing wrong???
Thanx,
-plh
 
K

Klatuu

What is your back end database?
It looks like you are using SQL Server syntax
The wildcard for Jet is * not %
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top