Filter on a subform problem

  • Thread starter Thread starter Paul Doree
  • Start date Start date
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
 
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
 
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
 
Back
Top