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

Print multiple records from criteria selected from a combo box

100+
P: 139
Hello,

I need to create a command button to print a report in Preview mode using the criteria from a combo box.

The combo box is unbound and holds a list of clients. I need the user to select the client, then when the button is hit the report lists all the records for that client.

I can write a script which prints a single record from a report, which is here:

Expand|Select|Wrap|Line Numbers
  1. Dim strReportName As String
  2.     Dim strCriteria As String
  3.  
  4.     If NewRecord Then
  5.         MsgBox "There is no History Report to run. Please select an existing record." _
  6.              , vbInformation, "Invalid Action"
  7.         Exit Sub
  8.     Else
  9.         strReportName = "rptWHistory"
  10.         strCriteria = "[lngRowID]= " & Me![lngRowID]
  11.         'strCriteria = "[lngRowID]='" & Me![lngRowID] & "'"
  12.  
  13.         DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
  14.  
  15.     End If 

But how do I modify this to take the value of my combo box cboClient, make it equal to the fieldname Client and then show all the records in my report?

Thanks!
Mar 6 '07 #1
Share this Question
Share on Google+
2 Replies


Rabbit
Expert Mod 10K+
P: 12,324
Hello,

I need to create a command button to print a report in Preview mode using the criteria from a combo box.

The combo box is unbound and holds a list of clients. I need the user to select the client, then when the button is hit the report lists all the records for that client.

I can write a script which prints a single record from a report, which is here:

Dim strReportName As String
Dim strCriteria As String

If NewRecord Then
MsgBox "There is no History Report to run. Please select an existing record." _
, vbInformation, "Invalid Action"
Exit Sub
Else
strReportName = "rptWHistory"
strCriteria = "[lngRowID]= " & Me![lngRowID]
'strCriteria = "[lngRowID]='" & Me![lngRowID] & "'"

DoCmd.OpenReport strReportName, acViewPreview, , strCriteria

End If


But how do I modify this to take the value of my combo box cboClient, make it equal to the fieldname Client and then show all the records in my report?

Thanks!
Same idea except:
Expand|Select|Wrap|Line Numbers
  1. strCriteria = "[Client] = '" & Me![Combobox Name] & "'"
Mar 6 '07 #2

NeoPa
Expert Mod 15k+
P: 31,270
For a full explanation and tutorial of the issue see (Example Filtering on a Form.).
Mar 7 '07 #3

Post your reply

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