By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 709 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

filter a continuous form

100+
P: 158
I have a continuous form that i need to filter by the contents of a textbox. The text box name is txtInvoiceNumber. This is what i have and it does not work....and its driving me crazy!!

Expand|Select|Wrap|Line Numbers
  1. Me.Filter = me.txtInvoiceNumber
  2. Me.FilterOn = True
Here's how it works, I have the user enter in customer data. When they press the "Create invoice" button then it passes the invoice number to the invoice form (not subform). I guarantee that the information is being pass successfully. This is where i need the invoice form filtered...am i anywhere near close!?

Thanks for your help
Matt
Sep 8 '08 #1
Share this Question
Share on Google+
4 Replies


Expert Mod 2.5K+
P: 2,545
Hi Jollywg. It doesn't work because you aren't specifying the field you want to filter. The filter clause should be structured as if it is a WHERE clause in SQL, but without the word WHERE.

I don't know the name of the field you are filtering, or whether it is a number or a text field, so replace the name of the dummy field below with the actual field from your query or table on which your form is based, and use the first line if your invoice number is a number, the second if it is text:

Expand|Select|Wrap|Line Numbers
  1. Me.Filter = "[your invoice number field] = " & me.txtInvoiceNumber
  2. Me.Filter = "[your invoice number field] = '" & me.txtInvoiceNumber & "'"
-Stewart
Sep 8 '08 #2

100+
P: 158
Here is how i am doing this...i had to modify the pseudo code you sent me.

Expand|Select|Wrap|Line Numbers
  1. Me.Filter = Me.txtInvoiceNum = "'" & varInvoiceNumber & "'"
  2. Me.FilterOn = True
Me.txtInvoiceNum is the textbox where the invoice number pop up in, and varInvoiceNumber is the string variable that the invoice number is assigned to when the invoice form is opened.

Right now the form does filter, it just filters to invoice number 0 (which doesn't exist) Any ideas?
Sep 9 '08 #3

Expert Mod 2.5K+
P: 2,545
Hi. What you have is not correct; a filter is, as I said, a WHERE clause without the word WHERE. You can only filter upon a field from the underlying table or query which is the recordsource of your form.

What I provided to you in skeleton form was correct; your attempt at it is not. Please re-read what I posted.

By the way, the 0 in the filter property at present is not an invoice number - it is the true/false result of comparing two variables for equality, and 0 represents False, meaning there was no match between the two items compared. Your 'filter' comes down to the following:

set filter property to the result of (the value in the control txtInvoiceNumber) = (the value of varInvoiceNumber)

which is meaningless.

-Stewart
Sep 9 '08 #4

100+
P: 158
OK my apologies...i wasn't understanding the code that i was supposed to be using. Me.filter = "[table field]" = filter value....i wasn't getting the "select" part of the line. Everything works wonderfully!

Thank you!
Sep 9 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.