473,396 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Print multiple records from criteria selected from a combo box

139 100+
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
2 2787
Rabbit
12,516 Expert Mod 8TB
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
32,556 Expert Mod 16PB
For a full explanation and tutorial of the issue see (Example Filtering on a Form.).
Mar 7 '07 #3

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

Similar topics

1
by: DD | last post by:
I have a mainform with a subform. The main form as a dropdown box "chooseDate", in the afterupdate event i requery the subform so all records with the same date are viewed. Now i only want to...
1
by: DD | last post by:
I have a mainForm with a subForm On the main form i have a combo with March 04, April 04 etc, you select a date and the subform shows all records for the selected date. I can print a selected...
0
by: Greg Strong | last post by:
Hello All, In the past I've used a combo box with the 'row source' being an Access SQL union query to select "All" or 1 for only 1 criteria in a query. An example is as follows: SELECT 0 As...
3
by: hmiller | last post by:
Hey everyone, I am having a hell of a time trying to set this menu system up. Here's what I'm trying to do. Combo Box One; is populated by names under properties "row source" "Phase 1"...
7
by: itm | last post by:
I have a mail out to send to a group of owners with multiple accounts. I want to limit the number of accounts that print on the first page to 20. I want remaining accounts to print on a second...
6
by: Dave | last post by:
On my form I have combo boxes. These combo boxes, after updating them, populate respective listboxes that are located below the combo boxes on the same form. I am trying to use a "generate...
7
by: Ceebaby via AccessMonster.com | last post by:
Hi All Here's hoping someone can help me with this. I have a report based on a query where the criteria for 4 of the fields is set from an unbound form. I want the user to be able to select any...
2
by: dlevene | last post by:
Hi - newbie here, be gentle. In Access 2003, I've created a report (based on a query) to produce mailing labels for all records where = "Community". is a combo-box field with the values coming from...
1
by: woodey2002 | last post by:
Hi Everyone and many thanks for your time.. I am trying to begin access and a bit of VBA i am enjoying it but I have a annoying problem I just can’t get any where on. My databse mostly includes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.