help with my code

  • Thread starter Thread starter Cam
  • Start date Start date
C

Cam

Hello,

I have a form with one selection criteria and also one with two selections
criteria to filter the results. The one selection criteria worked well, but
somehow the two criteria selection is not filtering. Here is a sample code of
one selection.

=IIf([Forms]![frm_FilterDialog]![SelectProdCode] Is Null,"","[ProductCode] =
Forms![frm_FilterDialog]![SelectProdCode]")

Question is can I put an AND function to this code to make it filter two
selections? I tried this, but didn't work. Any sugguestion.

=(IIf([Forms]![frm_FilterDialog]![SelectProdCode] Is Null,"","[ProductCode]
= Forms![frm_FilterDialog]![SelectProdCode]")) AND
(=IIf([Forms]![frm_FilterDialog]![SelectWorkCentre] Is Null,"","[WC] =
Forms![frm_FilterDialog]![SelectWorkCentre]"))
 
hi Cam,
=IIf([Forms]![frm_FilterDialog]![SelectProdCode] Is Null,"","[ProductCode] =
Forms![frm_FilterDialog]![SelectProdCode]")
Better use IsNull([Forms]![frm_FilterDialog]![SelectProdCode]).
Question is can I put an AND function to this code to make it filter two
selections? I tried this, but didn't work. Any sugguestion.

=IIf(IsNull([Forms]![frm_FilterDialog]![SelectProdCode]),
"",
"[ProductCode] = Forms![frm_FilterDialog]![SelectProdCode]")

Where do you apply this string? How do you apply it?

Can you describe with some examples what you like to achieve?

mfG
--> stefan <--
 
Hi Stefan,

I put this code in my Macro for opening form and report. Here is an example:
Open form macro.
Form Name: frm_SOW
View: Form
Where Condition: =IIf([Forms]![frm_FilterDialog]![SelectWorkCentre] Is
Null,"","[WC] = Forms![frm_FilterDialog]![SelectWorkCentre]")
Data Mode: Edit
Window Mode: Normal

Stefan Hoffmann said:
hi Cam,
=IIf([Forms]![frm_FilterDialog]![SelectProdCode] Is Null,"","[ProductCode] =
Forms![frm_FilterDialog]![SelectProdCode]")
Better use IsNull([Forms]![frm_FilterDialog]![SelectProdCode]).
Question is can I put an AND function to this code to make it filter two
selections? I tried this, but didn't work. Any sugguestion.

=IIf(IsNull([Forms]![frm_FilterDialog]![SelectProdCode]),
"",
"[ProductCode] = Forms![frm_FilterDialog]![SelectProdCode]")

Where do you apply this string? How do you apply it?

Can you describe with some examples what you like to achieve?

mfG
--> stefan <--
 
hi Cam,
I put this code in my Macro for opening form and report. Here is an example:
Open form macro.
Form Name: frm_SOW
View: Form
Where Condition: =IIf([Forms]![frm_FilterDialog]![SelectWorkCentre] Is
Null,"","[WC] = Forms![frm_FilterDialog]![SelectWorkCentre]")
Ahh, okay.

But if you need two criterias, this should work:

=IIf(IsNull([Forms]![frm_FilterDialog]![SelectProdCode]),
"True",
"[ProductCode] = Forms![frm_FilterDialog]![SelectProdCode]") &
" AND " &
IIf(IsNull([Forms]![frm_FilterDialog]![SelectWorkCentre]),
"True",
"[WC] = Forms![frm_FilterDialog]![SelectWorkCentre]")


mfG
--> stefan <--
 
Back
Top