form object value as query where issue

KeythStone

New member
Local time
Today, 07:36
Joined
May 10, 2012
Messages
6
I'm using a form as menu of criteria and the results defining a query. In design mode one field is filtered by:

Like IIf([Forms]![Aging_AR_quick_f]![prac_cbo]="","*",[Forms]![Aging_AR_quick_f]![prac_cbo]) & "*"

All fields in the form have a similar WHERE:

Like IIf([Forms]![formname]![cboname]="","*",[Forms]![formname]![cboname]) & "*"

The form is mostly made with comboboxes which use as rowsource a SQL select. Several combo box results are used in the WHERE:

SELECT DISTINCT dbo_AWF_supplemental_calculations_t.doctordep, dbo_AWF_supplemental_calculations_t.idxcode FROM dbo_AWF_supplemental_calculations_t WHERE dbo_AWF_supplemental_calculations_t.idxcode Like [Forms]![Aging_AR_quick_f]![prac_cbo] ORDER BY dbo_AWF_supplemental_calculations_t.doctordep;


I thought I got it but then some small adjustsments or something and it won't work. Query pulls all null, blank sheet.
When I try running query from query (rather than form btn) still same results. So it must be how I'm using the form values in Access Select query Wheres.

Any help, much appreciated,
KeythStone,
Stay Smooth
 
Quickly thinking, sometimes combo boxes on the form are not "" but are actually Null. I use the NZ function like there's no tomorrow to make sure I cover both "" and Null cases. So you could try something like;

Like IIf(NZ([Forms]![Aging_AR_quick_f]![prac_cbo],"")="","*",[Forms]![Aging_AR_quick_f]![prac_cbo]) & "*"

This has saved me boat loads of aggravation.
 

Users who are viewing this thread

Back
Top Bottom