Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't assign a value to filter. 1

Status
Not open for further replies.

Petemush

Technical User
Jun 21, 2002
255
GB
If someone solves this for me I'll be eternally grateful since it's the last problem in a long battle to get a piece of code running.

When I try to set the filter on a form through VBA it doesn't work. I get an error message saying I can't assign a value to this object. A message I've learned to hate.

The command I use is

form1.Filter = strSQL

where strSQL is a string which is a built up filter expression and form1 is the corresponding form.

I've also tried directly setting it with

form1.Filter = ("Course Source = 'External'")

but this has no effect.

Can anyone shed any light? Please? it will finish off a annoying bit of coding!

Cheers,

Pete
 
You need to watch your brackets, Pete.
If you are referencing a control with a space in it, you should put square brackets round it.
YOur example should be:

form1.Filter = ("[Course Source] = 'External'")

You need to build the [ and ] into the sql string you are using.

B ----------------------------------
Ben O'Hara
bo104@westyorkshire.pnn.police.uk
----------------------------------
 
OH MY GOD IT WORKS!

I cannot believe that that was it! I took the code from another thread and modified it but it originally came without the brackets so I assumed they weren't needed in a filter expression.

Thanks so much Ben, you have made my day.

Pete

Hmmmm, I think I might be a bit TOO happy about this!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top