469,126 Members | 1,252 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,126 developers. It's quick & easy.

print report based on query

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()
  3. Dim stDocName As String
  5. DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 
  7. With Forms!frmUrgentTriage1 
  9.     .tbo2CaseID.SetFocus 
  10.     .tbo2CaseID.Requery 
  11.     .Repaint 
  13. End With
  17.     stDocName = "Report1"
  18.     DoCmd.OpenReport stDocName, acNormal
  20. End Sub
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!

Mar 4 '09 #1
1 880
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).

Mar 4 '09 #2

Post your reply

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

Similar topics

2 posts views Thread by Sherwood Botsford | last post: by
4 posts views Thread by Jan | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.