473,382 Members | 1,648 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,382 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 4 '09 #1
1 960
Stewart Ross
2,545 Expert Mod 2GB
It would help us to give some kind of answer if you would kindly post the SQL statement which refers to that control. It is otherwise impossible to hazard a guess at what might be happening without something more specific to work on.

I am assuming that the SQL statement will be part of the recordsource for Report1.

Anyway, it is usually easier not to make the recordsource SQL dependent on the form, but instead to filter the report when it is opened (using the Where part of the DoCmd.OpenReport statement).

-Stewart
Mar 4 '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,...
4
by: Jan | last post by:
I am having problems trying to print a report based on a form. This is a search form only, no data input. There is a query that the form looks at, but then there are numerous comboxes that you...
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.