Yes/No as criteria in query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,
I am trying to create a form that will open a report based on the criteria
selected:

Query:
(Text) (Yes/No)
Neighborhood | Abate
[Forms]![frmSelectNeigh]![cboNBHDfrm] [Forms]![frmSelectNeigh]![Abate]

Form:
(Combo Box) | (Option Group)
cboNBHDfrm | Abate

In the Option Group I have three options -1 for checked 0 for not checked
and 1 for show all. The first to are ok since they are tied directly back to
the Yes/No I just can figure out the Show All.

I'm sure it is probably pretty simple. The answer is stuck on the tip of my
brain. I really appreciate your help in extracting this answer

Nick X
 
Try this, not sure about the names of the fields so try and change them to
suit you

Select * From TableName Where FieldName Like
IIf(Forms![FormName]![FieldName]=1,"*",Forms![FormName]![FieldName])
 
Nick X said:
Hi All,
I am trying to create a form that will open a report based on the criteria
selected:

Query:
(Text) (Yes/No)
Neighborhood | Abate
[Forms]![frmSelectNeigh]![cboNBHDfrm]
[Forms]![frmSelectNeigh]![Abate]

Form:
(Combo Box) | (Option Group)
cboNBHDfrm | Abate

In the Option Group I have three options -1 for checked 0 for not checked
and 1 for show all. The first to are ok since they are tied directly back
to
the Yes/No I just can figure out the Show All.

I'm sure it is probably pretty simple. The answer is stuck on the tip of
my
brain. I really appreciate your help in extracting this answer

Nick X

Hi Nick,

I think the simplest way to achive this is to use code rather than explicit
criteria in your query. In your command button's Click event (untested):

If Me.ogrMyOptionGroup <> 1 then
DoCmd.OpenReport "rptMyReport", acViewPreview, ,"[Abate] = " &
Me.ogrMyOptionGroup
Else
DoCmd.OpenReport "rptMyReport", acViewPreview
End If

HTH - Keith.
www.keithwilby.com
 
Thank you, works brilliantly! Combined with explicit criteria it achieves
exactly what I needed it to.

If Me.ogrAbate <> 1 Then
DoCmd.OpenReport "VLM Propertiesfrm", acViewPreview, , "[Abate] = " &
Me.ogrAbate
Else: DoCmd.OpenReport "VLM Propertiesfrm", acViewPreview
Neighborhood | Abate
[Forms]![frmSelectNeigh]![cboNBHDfrm]

Keith Wilby said:
Nick X said:
Hi All,
I am trying to create a form that will open a report based on the criteria
selected:

Query:
(Text) (Yes/No)
Neighborhood | Abate
[Forms]![frmSelectNeigh]![cboNBHDfrm]
[Forms]![frmSelectNeigh]![Abate]

Form:
(Combo Box) | (Option Group)
cboNBHDfrm | Abate

In the Option Group I have three options -1 for checked 0 for not checked
and 1 for show all. The first to are ok since they are tied directly back
to
the Yes/No I just can figure out the Show All.

I'm sure it is probably pretty simple. The answer is stuck on the tip of
my
brain. I really appreciate your help in extracting this answer

Nick X

Hi Nick,

I think the simplest way to achive this is to use code rather than explicit
criteria in your query. In your command button's Click event (untested):

If Me.ogrMyOptionGroup <> 1 then
DoCmd.OpenReport "rptMyReport", acViewPreview, ,"[Abate] = " &
Me.ogrMyOptionGroup
Else
DoCmd.OpenReport "rptMyReport", acViewPreview
End If

HTH - Keith.
www.keithwilby.com
 
Back
Top