Filter Code

J

James

When I type the code for a command button:

Private Sub SpecificationCmd_Click()
DoCmd.OpenForm "ProductSpec2",, [Supplier Code] = "SW11"
End Sub

to open the form ProductSpec2 filtered for Supplier
Code "SW11" it does not work. I am simply faced with the
form opened but with no filter placed upon it.

What am I doing Wrong?

Is there anyway I can adapt this code to apply a filter on
the "supplier code" field for whatever value happens to be
the current form?

Please, if anyone knows how to this, let me know, it's
driving me crazy!

Regards

James
 
R

Rick Brandt

James said:
When I type the code for a command button:

Private Sub SpecificationCmd_Click()
DoCmd.OpenForm "ProductSpec2",, [Supplier Code] = "SW11"
End Sub

to open the form ProductSpec2 filtered for Supplier
Code "SW11" it does not work. I am simply faced with the
form opened but with no filter placed upon it.

What am I doing Wrong?

The entire WHERE clause needs to be in Double Quotes. You can then use single quotes
inside of those for your string delimiter.

DoCmd.OpenForm "ProductSpec2",, "[Supplier Code] = 'SW11'"
 
V

Van T. Dinh

You are actually use the "wherecondition" argument rather than the "filter"
argument. In this case, you need 3 commas rather than 2. The
"wherecondition" is incorrect as well.

Try:

DoCmd.OpenForm "ProductSpec2", , , "[Supplier Code] = 'SW11'"
 

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