473,395 Members | 2,079 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,395 software developers and data experts.

print report based on query

12
why won't this work?

I have a form which has a text box: forms!frmCaseLog!tboCaseID the RecordSource for the form is tblCaseLog with the field [lngCaseID]

I would like to print a report with details entered into the form.

For the report RecordSource I have created a query "qryCurrentCaseInfo" which has in the criteria for [lngCaseID] the control above on the form "frmCaseLog"

I have a command button [cmdPrint] to print the report with the code

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdPrint_Click()
  2.  
  3. Dim stDocName As String
  4.  
  5. DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 
  6.  
  7. With Forms!frmUrgentTriage1 
  8.  
  9.     .tbo2CaseID.SetFocus 
  10.     .tbo2CaseID.Requery 
  11.     .Repaint 
  12.  
  13. End With
  14.  
  15.  
  16.  
  17.     stDocName = "Report1"
  18.     DoCmd.OpenReport stDocName, acNormal
  19.  
  20. End Sub
  21.  
  22.  
If I debug.print the control I get the Case ID value but I cannot get the query to use the Case ID value as the criterion for the report.

what gives? am I missing something?

thanks a bunch!

/jh
Mar 3 '09 #1
1 1335
PianoMan64
374 Expert 256MB
@JohnHo
Hey JohnHo,

You simply need to add the following to your Docmd.OpenReport settings.



Expand|Select|Wrap|Line Numbers
  1. 'OLD WAY
  2. DoCmd.OpenReport stDocName, acNormal 
  3.  
  4. 'NEW WAY
  5.  
  6. DoCmd.OpenReport stDocName, acNormal,,"[tboCaseID]=" & me.lngCaseID
  7.  
  8.  
The last Option if you read the help file for OpenReport, has an option to pass it a query string if you want something limited by a value in a certain field.

Hope that helps,

Joe P.
Mar 5 '09 #2

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

Similar topics

2
by: Roger | last post by:
I've got a table with one field (id) and one row (id = 1) I've got a query based on the table that calls a function select func(id) as idText from table The function 'func' is public...
2
by: Sherwood Botsford | last post by:
I'm new to access. I have an orienteering database that has information about locations all over the map. Each location has 0-N clues I've worked up a report that will print the locations,...
3
by: manning_news | last post by:
Using A2K. I've been asked to modify a report currently requiring only one date parameter to now accept a date range. The main report has 2 subreports and is not bound to a table or query. The...
2
by: B Garner | last post by:
Hi all Help please. I would like to automate the printing of a report. The report actually is a single page and prints a label. I would like to be able to print the report multiple times...
2
by: ghat12 | last post by:
Hi, I am trying to print a subform containing approx 50 columns in datasheet view. The printout cannot fit more than 8-10 columns. Does anyone know of any way to print all columns; i don't care...
3
by: sconard | last post by:
I have a subform in datasheet view that is the result of a complex vba custom query with a number of parameters. I would like to place a button on the parent form to print the datasheet view as a...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
11
by: Gord | last post by:
When I open a certain report, it runs some code that generates the records that will be displayed in that report. This works fine. When I go to print preview the report it appears that the code...
1
by: JohnHo | last post by:
why won't this work? I have a form which has a text box: forms!frmCaseLog!tboCaseID the RecordSource for the form is tblCaseLog with the field I would like to print a report with details...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.