View Single Post
  #9  
Old July 19th, 2004, 12:32 AM
Vincent DeLuca
external usenet poster
 
Posts: n/a
Default Display Parameter from Form on Report-Interesting

Ken-

The same Dialog Box is used to call both the query and the report. The same two date input boxes are used for both as well. The user selects any date from a calendar control and clicks a select week button. The code I have written automatically enters the startingdate and the endingdate for the week in the text boxes (or the user can manually enter the dates as well). Then the user may select either a Preview button, a Print button or a Close button. The preview button for now, calls the query and displays it on the screen. Eventually, When the report works, I will do a DoCmd.OpenReport acViewPreview instead of the query for the screen preview. The Print button is supposed to print the report with the same parameters as the Preview button and the query without asking the user for the input again.

Here is the code from the buttons:

Private Sub PrintReport_Click()
Dim strDocName As String

' Print report.

' On Error GoTo Err_Print_Click

' ValidateData

strDocName = "WeeklyPullsReport"
DoCmd.OpenReport strDocName, acViewNormal, , "[ShiftDate] BETWEEN #" & _
[Forms]![EmployeePullsDialogBox]![StartingDate] & "# AND #" & _
[Forms]![EmployeePullsDialogBox]![EndingDate] & "#"

Exit_Print_Click:
Exit Sub

Err_Print_Click:
' If Err = ConErrRptCanceled Then
' Resume Exit_Print_Click
' Else
' MsgBox Err.Description
' Resume Exit_Print_Click
'End If

End Sub


Private Sub btnPreview_Click()
On Error GoTo Err_btnPreview_Click

Dim stDocName As String

ValidateData

stDocName = "WeeklyPullsQuery"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_btnPreview_Click:
Exit Sub

Err_btnPreview_Click:
MsgBox Err.Description
Resume Exit_btnPreview_Click

End Sub
Private Sub btnCancel_Click()
On Error GoTo Err_btnCancel_Click


DoCmd.Close

Exit_btnCancel_Click:
Exit Sub

Err_btnCancel_Click:
MsgBox Err.Description
Resume Exit_btnCancel_Click

End Sub

Thanks for any assistance you can offer, Ken.

Vince



"Ken Snell" wrote:

Walk me through your process for opening the "dialog" form and for running
the report. Which form is used to open the dialog form? to run the report?
and which code steps are you running and when and in which form/report?

--

Ken Snell
MS ACCESS MVP

"Vincent DeLuca" wrote in message
...
Yes, Ken-

The dialog box form never closes even after the report is closed. The

values remain in the text boxes the whole time.

Thanks.

Vincent DeLuca


"Ken Snell" wrote:

Are you keeping the form open while the report is being generated? You

need
to do that.

--

Ken Snell
MS ACCESS MVP

"Vincent DeLuca" wrote in

message
...
Ken-

Would the data that is passed from the query that is based upon a
parameter text box form be limited to the range specified by the

parameter
query as shown in a report based upon that query, or would you need to

"pass
along" the values to limit the data to the range desired within the

report
itself?

I have successfully created a parameter query based upon form text box
data for the desired date range that displays the accurate data, but

cannot
get a report based upon that query to print. The same report when

pulling
the same data in which I type in the parameters in popup boxes (based

upon a
copy of the same query without form references) works fine. I cannot

locate
the reason for this.

The query with the references to the dialog box form text boxes has

the
following parameters:

[Forms]![EmployeePullsDialogBox]![StartingDate] Date/Time
[Forms]![EmployeePullsDialogBox]![EndingDate] Date/Time

And in the [Date] column of this crosstab query:

Where

Between [Forms]![EmployeePullsDialogBox]![StartingDate] AND
[Forms]![EmployeePullsDialogBox]![EndingDate]

The same form without the dialog box references has the following
parameters:

StartingDate Date/Time
EndingDate Date/Time

Why would I be running into this problem?

Thanks.

Vincent DeLuca




"Ken Snell" wrote:

The Forms reference is interpreted by the report as meaning that

actual
form...not the parameter that you passed to the query. The query

notes
that
the form is not open and asks you for the value; the report notes

that
the
form is not open and tells you it cannot find the value you want

(the
error
in the textbox).

Note that a parameter passed to the query is not available to the

report
unless you also put that exact same parameter in the control source

of a
textbox on the report; then you can "pass" it along.

--

Ken Snell
MS ACCESS MVP

"sara" wrote in message
...
Interesting - that works! You just saved me what would
have been wasted debigging time.

BUT, I was having the problem testing the report on its
own - and the query's parameter was Forms!
F_PrintEEReports...., and I was typing in the date. Why
didn't that date carry through to the report? Does this
mean the users can't run the report from Reports or
Groups - only from the Form if they want the date to
appear?

Thanks so much. I can't tell you how wonderful I find
this community. I am the only person in this company who
does IT/applications, so there's no one to ask!
Sara


-----Original Message-----
Are you keeping the F_PrintEEReports form open while the
report is being
"printed"? If you close it beforehand, the report cannot
read the value from
the form's control.

--

Ken Snell
MS ACCESS MVP

"sara" wrote in
message
...
I have a Form to run reports. The field the user inputs
is often needed to display in the report's heading. For
example, the user enters "Week Ending Date" and I pull
all
the data for the week using Between WeekEndingdate and
DateAdd -6.

I want to display either BOTH dates, and sometimes just
the one date the user entered in the report heading, and
it always comes up #Name?. I can't find any reference
in
Help, either.

=([Forms]![F_PrintEEReports]![getWkMoDate])
(I've tried it with and without the parenthesis)

I can't figure this out!

Thanks,
Sara (newbie to code and forms)


.