Filter on a subform problem

P

Paul Doree

Hi all,

I have a text box on a sub form which, when the user enters a job number, I
want the data on the subform to be filtered to that job number. I've been
trying various syntax but can't get it to work.

In the after update event of the text box (called txtjobnumberforfilter)
I've currently got:

Me.Filter = "JobNumber = " & Me!txtjobnumberforfilter
Me.FilterOn = True

JobNumber is the name of the field on the subform.

I get an error saying 'You cancelled the previous operation' and the debug
window drops me back to the Me.FilterOn = True line.

Can anyone help here. I've been at it over an hour on this.

Cheers,

Paul
 
A

Allen Browne

There is something wrong with the filter string, or a reason why it cannot
be applied.

Suggetions:
1. Make sure txtjobnumberforfilter is unbound.

2. Make sure txtjobnumberforfilter is not null.

3. If JobNumber is a Text field (not a Number field), use extra quotes:
Me.Filter = "JobNumber = """ & Me!txtjobnumberforfilter & """"
Explanation:
http://allenbrowne.com/casu-17.html

4. Explicitly save before trying to apply the filter:
If Me.Dirty then Me.Dirty = false
 
P

Paul Doree

Allen,

Works perfectly - thank you


Allen Browne said:
There is something wrong with the filter string, or a reason why it cannot
be applied.

Suggetions:
1. Make sure txtjobnumberforfilter is unbound.

2. Make sure txtjobnumberforfilter is not null.

3. If JobNumber is a Text field (not a Number field), use extra quotes:
Me.Filter = "JobNumber = """ & Me!txtjobnumberforfilter & """"
Explanation:
http://allenbrowne.com/casu-17.html

4. Explicitly save before trying to apply the filter:
If Me.Dirty then Me.Dirty = false
 

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