Where Clause in on open form event

B

Bill

I have several "MainContact" forms which are opened from
various buttons on a switchboard. As it stands now the
only difference in these forms are the record sources
(queries). The only difference in the queries are some
criteria that allow me to see only certain contacts.

I know this is ineffecient, and I think that I could only
have one form and Vary the Whereclause in the
DoCmd.openform (isn't that correct).

My problem has been that despite my efforts I can't find
an example of the correct syntax for this clause. When I
try to copy and paste the where condition from the SQL I
get a variety of error messages depending on which
incorrect syntax I use.

Can someone please show me the correct syntax to use in
this condition. The form name I am opening is
frmMainContact. Its record source is tblCompany. The field
in the table upon which I want to select is "Description".
In one case, all records I want to view
have "PlasticFabricFilm" in this field. There are many
other selections I'd like to make in this manner but once
I see the syntax for one I can easily do the others

Thanks

Bill
 
D

Dan Artuso

Hi,
The syntax would be:
DoCmd.OpenForm "frmMainContact",,,"[Description] = 'PlasticFabricFilm'"
 
D

Dan Artuso

Hi,
No, you'd have to alter the query that is the form's record source or set the order by property of the form.

--
HTH
Dan Artuso, Access MVP


Bill said:
-----Original Message-----
Hi,
The syntax would be:
DoCmd.OpenForm "frmMainContact",,,"[Description] = 'PlasticFabricFilm'"

--
HTH
Dan Artuso, Access MVP


"Bill" <[email protected]> wrote in
message news:[email protected]...
.
Bless your heart, Thanks
Is there anyway to stick an ORDER BY in there?
 

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