Re: Query from field w/multiple values
From: PC Datasheet (nospam_at_nospam.spam)
Date: 01/11/05
- Next message: LeAnne: "Re: IIF statement or Switch()"
- Previous message: Chris: "Displaying a list of nulls only"
- In reply to: James Kendall: "RE: Query from field w/multiple values"
- Next in thread: James Kendall: "Re: Query from field w/multiple values"
- Reply: James Kendall: "Re: Query from field w/multiple values"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 11 Jan 2005 19:54:54 GMT
Change your Where statement to:
WHERE [Scrap Data].[Plant Code]=[Enter Plant1 number] Or _
[Scrap Data].[Plant Code]=[Enter Plant2 number] Or _
[Scrap Data].[Plant Code]=[Enter Plant3 number] Or _
[Scrap Data].[Plant Code]=[Enter Plant4 number]
Use as many "Or" statements as you have plants.
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
resource@pcdatasheet.com
www.pcdatasheet.com
"James Kendall" <JamesKendall@discussions.microsoft.com> wrote in message
news:388B3AB5-24C2-4F2C-B8BD-96497777B976@microsoft.com...
> What I mean is can I enter multiple criteria in the same criteria request?
> For example I have a query that asks for a plant code. I can enter one
> number, say 41, and it will query just fine. If I try to enter two plant
> codes, say 41 and 44, it will return nothing. I want the operator to be
able
> to enter any number of plant codes they need in the same criteria field.
>
> If I wrote it in SQL with hard entered plant codes it would look like
this:
> SELECT [Scrap Data].[Plant Code], Count([Scrap Data].[Plant Code]) AS
> [CountOfPlant Code]
> FROM [Scrap Data]
> WHERE ((([Scrap Data].[Plant Code])=41)) OR ((([Scrap Data].[Plant
Code])=44))
> GROUP BY [Scrap Data].[Plant Code]
>
> If I write it in user entry format it looks like this:
> SELECT [Scrap Data].[Plant Code], Count([Scrap Data].[Plant Code]) AS
> [CountOfPlant Code]
> FROM [Scrap Data]
> WHERE ((([Scrap Data].[Plant Code])=[Enter Plant number(s)]))
> GROUP BY [Scrap Data].[Plant Code];
>
> is there any way to make the criteria [Enter Plant number(s)] be able to
> allow multiple plants so that the query will run it like the first
mentioned
> SQL if I entered plant codes 41 and 44? Meaning enter multiple criteria
in
> the same criteria request box for the query.
>
> "JL" wrote:
>
> > Hi James,
> >
> > Using the "[Criteria]" should let you change the value everytime when
you
> > execute your query.
> >
> > There is another way that you can query more than one value.
> > You can build a table that will contain all the values that you want to
> > retrieve in a single field. Then you can JOIN them and get your records
back.
> >
> > Hope this helps.
> >
> >
> > "James Kendall" wrote:
> >
> > > Is there a way to set up a field so that a query will read the
value(s) as
> > > criteria?
> > > I use [plant] but that seems to only allow me to enter one value. Can
I get
> > > it to be able to enter two or three? If I can not do it that way is
there a
> > > way to get the query to change a value for the criteria?
> > > --
> > > Thank you for your time.
> > > Windows NT
> > > Office 97
- Next message: LeAnne: "Re: IIF statement or Switch()"
- Previous message: Chris: "Displaying a list of nulls only"
- In reply to: James Kendall: "RE: Query from field w/multiple values"
- Next in thread: James Kendall: "Re: Query from field w/multiple values"
- Reply: James Kendall: "Re: Query from field w/multiple values"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|