View Full Version : Parameter Query to Report


aands1998
08-13-2010, 02:58 PM
Hello,
I used the following link to set up a form that feeds info back to a parameter query that I would like to result in a report view.
http://office.microsoft.com/en-us/access-help/using-parameters-with-queries-and-reports-HA001117077.aspx (http://office.microsoft.com/en-us/access-help/using-parameters-with-queries-and-reports-HA001117077.aspx)
The form is feeding back to the query correctly but the output is the query view not in the format of the report.
Any help would be appreciated.
Thanks

PNGBill
08-13-2010, 05:47 PM
When you say Format of the Report?? what do you mean?? It doesn't have the "Look" you want or the Data you expected??

The "Look" is the Reports Format. You have to do this yourself.

If you want a Report to look as your Form Does. Save the Form as a report and do a little editing and you have the Report that looks similar to your Form. (Command Buttons on a Form are just pictures on a report.)

If you mean your Record Source doesn't reflect what the form showed then possibly all you need to do is add some link criteria to the button you click on your Form to get the report to open.

Of course the big unknown is what is in the query the report uses?? if this data is not what you want then why the surprise??

If you are on a Form which displays Apples and you click a button to Print a Report on Apples (or so the caption says) but the report you open has a query record source all about Pears then of course, your report will be Pears.

aands1998
08-13-2010, 09:04 PM
I have a form that feeds info into a parameter query from there the coding was supposed to open a report displaying the parameter query results. What happens is the query opens and not the report - the query has the correct information based on the info entered into the form so the problem isn't there. I was looking at the coding again and the "ok" button on the form has the following:

Private Sub cmdOK_Click()
Me.Visible = False
DoCmd.OpenQuery "qryTraining", acViewNormal, acEdit
DoCmd.Close acForm, "frmDivisionDialog"
End Sub

Which, if I am reading it correctly is instructing it to open the query - hence my problem (I think). So, I thought if I changed it to:

DoCmd.OpenReport "Training Report", acViewPreview, acEdit

I would get what I wanted. What I see is something flash up on the screen for a second but not sure what it is. I used acViewPreview so that it wouldn't print automatically (something I learned from another post).
So where am I going wrong on this coding?
Thanks!

PNGBill
08-13-2010, 09:56 PM
You appear to be opening a query - ok now you say you have edited that line of code to open a report.

What does the next line say??
To me you are telling it to close the form.
Remark this line out ' and see what happens

Also, what is the me.Visible for??

here is my code to open a report using data on the form

Private Sub CmdFrmSingleLoanStatement_Click()
On Error GoTo Err_CmdFrmSingleLoanStatement_Click

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[LDPK] = " & Me.[LDPK]
DoCmd.OpenReport "RptStatementNewStyle", acViewPreview, , strWhere
End If


Exit_CmdFrmSingleLoanStatement_Click:
Exit Sub

Err_CmdFrmSingleLoanStatement_Click:
MsgBox Err.Description
Resume Exit_CmdFrmSingleLoanStatement_Click



I don't need to woryy about the query.

The query has All Data.

The report filters the data as per the Link Criteria instruction.

aands1998
08-14-2010, 06:17 AM
I have it working now. Thanks!