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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report from a dialog form, using ALL from a COMBO Box 2

Status
Not open for further replies.

Sisco

Technical User
Jul 11, 2000
12
US
In Access 97, I have a report that prints based on the field selected from a combo box form.&nbsp;&nbsp;The report uses a query as the recordsource, where the field Criteria in the query =forms!frmForm1!cmbfield1 .&nbsp;&nbsp;This works great, but I'm trying to get the combo box to offer up &quot;(All)&quot; and then use that value in my query.&nbsp;&nbsp;&nbsp;I used the example by Dev Ashish, but am still having trouble getting this to work.<br><br>Can someone help?
 
Are you having trouble getting the (All) into your combo box? or getting the query to respond to a selection of (All)?<br><br>If it is the latter, you can type this in the criteria field:<br>iif((forms!frmForm1!cmbfield1 = &quot;(All)&quot;), &quot;Like '*'&quot;, forms!frmForm1!cmbfield1)<br><br>If the combo box is the result of a query, to get (All) in the list, you may have to go with a value list and build the row source via a recordset, where you add your (All) to the list.&nbsp;&nbsp;Make sense?&nbsp;&nbsp;I can provide some additional assistance with this if you need. <p>-Chopper<br><a href=mailto: > </a><br><a href= > </a><br>
 
Thanks for the reply, Chopper.&nbsp;&nbsp;The problem is the latter;&nbsp;&nbsp;getting the query to respond to a selection of (All).&nbsp;&nbsp;I tried the iif((forms!frmForm1!cmbfield1 = &quot;(All)&quot;), &quot;Like '*'&quot;, forms!frmForm1!cmbfield1).&nbsp;&nbsp;There is something that it doesn't like about the Like syntax, as the query returns no records.&nbsp;&nbsp;Maybe there's something wrong with the &quot; or ' placement.&nbsp;&nbsp;I looked in HELP (tee hee!)&nbsp;&nbsp;Let me know if there is a syntax problem.<br><br>Thanks, Chopper!<br><br>
 
I'm not sure this code's source, but I've used it successfully, and it accomplishes the basics of what you are looking to do. <br><br>I'm currently ripping through my archives trying to find a very cool piece of code for a union query which can be used to add an '(All)' selection to the combo box, but have yet to find where I might have hidden it, or figure out how to replicate it.<br><br>In your query in the criteria line under the field you want to test, write:<br><br>Like IIf(Len([Forms]![Your Form Name]![Your TextBox Name])&gt;0,[Forms]![Your Form Name]![Your TextBox Name],&quot;*&quot;)<br><br>If the textbox on your form is empty, this field will not be limited but if the textbox on your form is filled in, it will be used to limit the query to matching entries in the table.<br><br>HTH (and thank you to the original poster of this code fragment),<br><br>Drew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top