A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

passing to criteria to a query



 
 
Thread Tools Display Modes
  #1  
Old April 24th, 2008, 06:36 PM posted to microsoft.public.access.forms
Question Boy[_2_]
external usenet poster
 
Posts: 179
Default passing to criteria to a query

I have a query in which I set the criteria of a field to the value of a combo
box on my form.

On the form, the combo box has three values
A
B
A Or B

When the 1st 2 are used the query run properly. However the third does not
(return nothing, although individually they do). What must I change so that
it will accept multiple criteria?

QB
  #2  
Old April 24th, 2008, 06:47 PM posted to microsoft.public.access.forms
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default passing to criteria to a query

Please post the SQL statement of your query.

Regards

Jeff Boyce
Microsoft Office/Access MVP


"Question Boy" wrote in message
news
I have a query in which I set the criteria of a field to the value of a
combo
box on my form.

On the form, the combo box has three values
A
B
A Or B

When the 1st 2 are used the query run properly. However the third does
not
(return nothing, although individually they do). What must I change so
that
it will accept multiple criteria?

QB



  #3  
Old April 24th, 2008, 06:49 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default passing to criteria to a query

Post the SQL of the query, please.
--
Dave Hargis, Microsoft Access MVP


"Question Boy" wrote:

I have a query in which I set the criteria of a field to the value of a combo
box on my form.

On the form, the combo box has three values
A
B
A Or B

When the 1st 2 are used the query run properly. However the third does not
(return nothing, although individually they do). What must I change so that
it will accept multiple criteria?

QB

  #4  
Old April 24th, 2008, 06:58 PM posted to microsoft.public.access.forms
Question Boy[_2_]
external usenet poster
 
Posts: 179
Default passing to criteria to a query

SELECT Count([dtApproR]) AS [on time]
FROM ([tbl_Plan] INNER JOIN [qry_last approved] ON [tbl_Plan].PlanifIngId =
[qry_Approved].PlanifIngId) INNER JOIN [PARAMETRE] ON [tbl_Plan].ProNo =
[PARAMETRE].[Number]
WHERE ((([tbl_Plan].dtApproR)=[DateApproP]) AND ((IIf([Type
A]=True,"A",IIf([Type B]=True,"B","C"))) Like [Forms]![frm_rpt_Stats Appro et
Fab]![Combo0]));


"Jeff Boyce" wrote:

Please post the SQL statement of your query.

Regards

Jeff Boyce
Microsoft Office/Access MVP


"Question Boy" wrote in message
news
I have a query in which I set the criteria of a field to the value of a
combo
box on my form.

On the form, the combo box has three values
A
B
A Or B

When the 1st 2 are used the query run properly. However the third does
not
(return nothing, although individually they do). What must I change so
that
it will accept multiple criteria?

QB




  #5  
Old April 24th, 2008, 07:05 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default passing to criteria to a query

Try

SELECT Count([dtApproR]) AS [on time]
FROM ([tbl_Plan] INNER JOIN [qry_last approved] ON [tbl_Plan].PlanifIngId =
[qry_Approved].PlanifIngId) INNER JOIN [PARAMETRE] ON [tbl_Plan].ProNo =
[PARAMETRE].[Number]
WHERE [tbl_Plan].dtApproR=[DateApproP]
AND (([Type A]=True AND [Forms]![frm_rpt_Stats Appro et Fab]![Combo0] IN
("A", "A or B"))
OR ([Type B=True AND [Forms]![frm_rpt_Stats Appro et Fab]![Combo0] IN ("B,
"A or B")))

BTW, the fact that you've got fields named Type A and Type B is usually
indicative of the fact that you haven't correctly normalized your tables.
Check some of the resources Jeff Conrad has at
http://www.accessmvp.com/JConrad/acc...abaseDesign101
to learn how to correct your design.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"Question Boy" wrote in message
...
SELECT Count([dtApproR]) AS [on time]
FROM ([tbl_Plan] INNER JOIN [qry_last approved] ON [tbl_Plan].PlanifIngId
=
[qry_Approved].PlanifIngId) INNER JOIN [PARAMETRE] ON [tbl_Plan].ProNo =
[PARAMETRE].[Number]
WHERE ((([tbl_Plan].dtApproR)=[DateApproP]) AND ((IIf([Type
A]=True,"A",IIf([Type B]=True,"B","C"))) Like [Forms]![frm_rpt_Stats Appro
et
Fab]![Combo0]));


"Jeff Boyce" wrote:

Please post the SQL statement of your query.

Regards

Jeff Boyce
Microsoft Office/Access MVP


"Question Boy" wrote in message
news
I have a query in which I set the criteria of a field to the value of a
combo
box on my form.

On the form, the combo box has three values
A
B
A Or B

When the 1st 2 are used the query run properly. However the third does
not
(return nothing, although individually they do). What must I change so
that
it will accept multiple criteria?

QB





  #6  
Old April 24th, 2008, 07:44 PM posted to microsoft.public.access.forms
Question Boy[_2_]
external usenet poster
 
Posts: 179
Default passing to criteria to a query

Ya I know. I took over someone else's work and the boss doesn't want me to
spend time fixing such issues. It works, don't touch....

Isn't the first time it creates problems for me. I spent more time working
around it then solving it.




"Douglas J. Steele" wrote:

Try

SELECT Count([dtApproR]) AS [on time]
FROM ([tbl_Plan] INNER JOIN [qry_last approved] ON [tbl_Plan].PlanifIngId =
[qry_Approved].PlanifIngId) INNER JOIN [PARAMETRE] ON [tbl_Plan].ProNo =
[PARAMETRE].[Number]
WHERE [tbl_Plan].dtApproR=[DateApproP]
AND (([Type A]=True AND [Forms]![frm_rpt_Stats Appro et Fab]![Combo0] IN
("A", "A or B"))
OR ([Type B=True AND [Forms]![frm_rpt_Stats Appro et Fab]![Combo0] IN ("B,
"A or B")))

BTW, the fact that you've got fields named Type A and Type B is usually
indicative of the fact that you haven't correctly normalized your tables.
Check some of the resources Jeff Conrad has at
http://www.accessmvp.com/JConrad/acc...abaseDesign101
to learn how to correct your design.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"Question Boy" wrote in message
...
SELECT Count([dtApproR]) AS [on time]
FROM ([tbl_Plan] INNER JOIN [qry_last approved] ON [tbl_Plan].PlanifIngId
=
[qry_Approved].PlanifIngId) INNER JOIN [PARAMETRE] ON [tbl_Plan].ProNo =
[PARAMETRE].[Number]
WHERE ((([tbl_Plan].dtApproR)=[DateApproP]) AND ((IIf([Type
A]=True,"A",IIf([Type B]=True,"B","C"))) Like [Forms]![frm_rpt_Stats Appro
et
Fab]![Combo0]));


"Jeff Boyce" wrote:

Please post the SQL statement of your query.

Regards

Jeff Boyce
Microsoft Office/Access MVP


"Question Boy" wrote in message
news I have a query in which I set the criteria of a field to the value of a
combo
box on my form.

On the form, the combo box has three values
A
B
A Or B

When the 1st 2 are used the query run properly. However the third does
not
(return nothing, although individually they do). What must I change so
that
it will accept multiple criteria?

QB





 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:23 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.