command button to open report

  • Thread starter Thread starter LTOSH
  • Start date Start date
L

LTOSH

I have a form where I fill in the information i desire (using combo boxes)
then have a command button that when clicked it opens a report in print
preview where i can print it from there.

When i do this my report keeps the information from the last time i filled
out the form along with the new info. How do i have my report keep only the
current information i have inputed?

thanks!!!
 
What reports display depends on the table(s) to which they're bound.

What's the RecordSource of the report? Is it a query with parameters based
on controls on the form you use to capture the user input?

How do you open the report?
 
after looking...the record source for both my form and my report is the
same..it is a table...tblClientWorkout.

The form...I am creating a workout using combo box's from a table.
 
I have a form where I fill in the information i desire (using combo boxes)
then have a command button that when clicked it opens a report in print
preview where i can print it from there.

When i do this my report keeps the information from the last time i filled
out the form along with the new info. How do i have my report keep only the
current information i have inputed?

thanks!!!

What is the exact code you are using to open the report?

I suspect you are entering data into the form then clicking the
command button to print the report with this new data.
Access does not save the data entered into your form until you
navigate to another record, close the form, or explicitly save the
data.

In your code to open the report, save the data first.

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "ReportName", acPreview

If this doesn't resolve your problem, then post back with the exact
code you are using and more information about your set-up.
 
If the RecordSource for your report is a table, then unless you're changing
data in that table on your form, you're not going to see any difference each
time you open the report.
 
hi fredg,

thanks for your help. I added the information you gave and it didn't appear
to do anything...when i went back into my form and inputed data then clicked
my preview report button, it showed all the information i had been putting
in...so...this is the code attached to the Command Button on my form:

Private Sub PreveiwClientWorkout_Click()
On Error GoTo Err_PreveiwClientWorkout_Click

Dim stDocName As String

stDocName = "rpt_tblClientWorkout"
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport stDocName, acPreview

Exit_PreveiwClientWorkout_Click:
Exit Sub

Err_PreveiwClientWorkout_Click:
MsgBox Err.Description
Resume Exit_PreveiwClientWorkout_Click

End Sub

Now here is my set up. I have table (tblExercises) that lists exercises. I
have a second table (tblClientWorkout) that has fields for workout day,
exercise name, sets, reps, weight etc. I then have a form (frmClientWorkout)
where i create a workout from the tblClientWorkout. I use combo box to input
the exercises. Once i have input all the information I then click the
command button to preview report for printing.

I'm not sure that i have done this as easily as it could be...all i want to
do is create a workout based on the table i have with exercises and print it.

Thanks for your help and thoughts and directions.
LTOSH
 
Back
Top