help with my code

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]"))
 
S

Stefan Hoffmann

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 <--
 
C

Cam

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 <--
 
S

Stefan Hoffmann

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 <--
 

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