Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If combo has no selection, then criteria is null, otherwise use select

Status
Not open for further replies.

MrsMope

Technical User
Oct 18, 2004
125
US
Hi I have a form with a combobox on it that allows a user to choose a salesperon on which to run a report. I also want the user to be able to run the report for all sales people. I have a created a cross tab query off of this query to populate my report. How do I allow users to either select one or all ?
 
thread703-608847

I found the above thread that explains how to do what I want, but the "*" command doesn't seem to be functioning, any ideas why? here is my code for the query:
Code:
SELECT user_tblAccountProp.Salesman, user_tblAccountProp.ID, user_tblAccountProp.Description AS Accountname, user_tblJobProp.Selling_Price, user_tblJobProp.Date_Shipped
FROM user_tblJobProp INNER JOIN (user_tblAccountChild INNER JOIN user_tblAccountProp ON user_tblAccountChild.Parent_ID = user_tblAccountProp.ID) ON user_tblJobProp.ID = user_tblAccountChild.Child_ID
GROUP BY user_tblAccountProp.Salesman, user_tblAccountProp.ID, user_tblAccountProp.Description, user_tblJobProp.Selling_Price, user_tblJobProp.Date_Shipped
HAVING (((user_tblAccountProp.Salesman)=IIf([Forms]![frmReportListing]![cboEmployName] Is Null,"*",[Forms]![frmReportListing]![cboEmployName])));
 
May be because * is a wildcard character, so try testing for it with LIKE rather than = otherwise your query is looking for salesman with a name of * rather than all salesmen.

i.e.
.
.
.
HAVING (((user_tblAccountProp.Salesman) LIKE IIf([Forms]![frmReportListing]![cboEmployName] Is Null,"*",[Forms]![frmReportListing]![cboEmployName])));

[pc2]
 
That did it, hallelujah. Thanks so much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top