By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,841 Members | 1,761 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,841 IT Pros & Developers. It's quick & easy.

Combo box to display individual items or all

P: 13
I have created a combo box for my form. This box displays the individual items properly and runs the report on that particular selection. My question is. How do I code so that a selection of display All items on the combo box?
Thank you
Jose
Dec 28 '06 #1
Share this Question
Share on Google+
2 Replies


P: 76
I have created a combo box for my form. This box displays the individual items properly and runs the report on that particular selection. My question is. How do I code so that a selection of display All items on the combo box?
Thank you
Jose
Can you post the code you have in your command button? I'm thinking what you'll want is to display everything if the combo box value is blank. For the first line here, you may want to use
Expand|Select|Wrap|Line Numbers
  1.  If IsNull(me.cboName.value) 
Expand|Select|Wrap|Line Numbers
  1. If me.cboName.value) = "" then strWhereClause = "[Field] = '*'"
  2. Else
  3. strWhereClause = "[Field] = '" & cboName.Value & "'"
  4. End If
  5. DoCmd.OpenReport "ReportName", acViewPreview
  6. With Reports![ReportName]
  7.     .Filter = strwhereclause
  8.     .FilterOn = True
  9. End With
  10. DoCmd.Close acForm, Me.Name 
Dec 28 '06 #2

NeoPa
Expert Mod 15k+
P: 31,660
Fundamentally this is right.
You may want to try a slightly more straghtforward approach though :
Expand|Select|Wrap|Line Numbers
  1. Dim strWhereClause As String
  2.  
  3. strWhereClause = "[Field] Like '" & Nz(cboName,"*") & "'"
  4. DoCmd.OpenReport "ReportName", acViewPreview, , strWhereClause
Dec 30 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.