Filter button / Select statement / String part

K

Kevin Bruce

On a form with 20 filter buttons, I have one that is designated to pull any
record where the so-called "DistrictAndAffiliationID" begins with the
letters "SD".

Case Is = 17
Me.Filter = "Left$(DistrictAndAffiliationID, 2) = 'SD'"
Me.FilterOn = True

This doesn't run, however. Am I doing something wrong?


================================
Kevin Bruce
Program Coordinator
ArtStarts in Schools
301 - 873 Beatty Street
Vancouver, BC V6B 2M6

ph:604-878-7144 ext.3
fx: 604-683-0501

web: www.artstarts.com
 
J

Jonathan Parminter

-----Original Message-----
On a form with 20 filter buttons, I have one that is designated to pull any
record where the so-called "DistrictAndAffiliationID" begins with the
letters "SD".

Case Is = 17
Me.Filter = "Left$(DistrictAndAffiliationID, 2) = 'SD'"
Me.FilterOn = True

This doesn't run, however. Am I doing something wrong?


================================
Kevin Bruce

Hi Kevin,
try setting a breakpoint in the procedure and then
stepping through it as it runs. When you do this check the
value in this field - does it actually begin with 'SD' ?

Maybe there is something else that is causing the
problem...

Luck
Jonathan
 
K

Kevin Bruce

Thanks for your assistance, Jonathon.

There is more to my problem than meets the eye...

The same code in a copy of the database from a month ago runs just fine. I
have imported that form and code into the current database but I get the
same errors. I have imported the current form and code into the copy and it
runs okay. So, something has happened to my data in the past month.

If, in the current database, I replace the line:

Me.Filter = "Left$(DistrictAndAffiliationID, 2) = 'SD'"

with something like:

Me.Filter = "DistrictAndAffiliationID, = 'SD36'"

that runs fine as well, pulling out all those records associated with SD36.
So, that means that these records do indeed start with "SD" as you suggested
I check.

I am completely mystified as to what to try next. Any suggestions?

_Kevin
 
J

Jonathan Parminter

-----Original Message-----
Thanks for your assistance, Jonathon.

There is more to my problem than meets the eye...

The same code in a copy of the database from a month ago runs just fine. I
have imported that form and code into the current database but I get the
same errors. I have imported the current form and code into the copy and it
runs okay. So, something has happened to my data in the past month.

If, in the current database, I replace the line:

Me.Filter = "Left$(DistrictAndAffiliationID, 2) = 'SD'"

with something like:

Me.Filter = "DistrictAndAffiliationID, = 'SD36'"

that runs fine as well, pulling out all those records associated with SD36.
So, that means that these records do indeed start with "SD" as you suggested
I check.

I am completely mystified as to what to try next. Any suggestions?

_Kevin


Kevin
these 2 are different in what they are acheiving
Me.Filter = "Left$(DistrictAndAffiliationID, 2) = 'SD'"
Me.Filter = "DistrictAndAffiliationID = 'SD36'"

the first is looking for values that match 'SD'
the second is looking for exact match with 'SD36'

try
Me.Filter = "DistrictAndAffiliationID like 'SD*'"

Luck
Jonathan
 
K

Kevin Bruce

Thanks, Jonathon. That's licked the problem.

Now all I have to do is figure out who went into the code window and deleted
the ' * ' from my original code!

_Kevin
 

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

Similar Threads

Type mismatch error 3
OLE error message 1
query by month 2
list box on subform 1
DLookup in a query 2
Option group & combo box relationship 1
Automation warnings 1
Converting hypertext to text 2

Top