Preview Report Command That Can Do More

ALewis06

Registered User.
Local time
Today, 04:21
Joined
Jun 21, 2012
Messages
124
Access 2010 - I have a search form where end users enter parameters. I used the command wizard and created a preview report command button so the report tab comes up in preview mode just fine. I also created a Clear Entry command button that works. However if I leave the report open in preview mode and go back to the form tab, hit the Clear Entry button, then enter new parameters, the report data doesn't change from the previous entry. My questions are:

1. Will the end user have to close the report manually each time before entering new parameters?

2. If not, where is the Close Report command button? I could only find Close Form.

3. What's the code to create a command button to refresh the report?

4. Finally, can everything (preview report, clear entry, refresh data) be done using just 1 command button? Can't I add all the code I need behind one command?

Here's the code such as it is that I have in there now:

Private Sub cmdClear_Click()
Me.GroupName = Null
Me.firstName = Null
Me.lastName = Null
Me.EmailAddress = Null
End Sub
Private Sub cmdCloseReport_Click()
DoCmd.Close
End Sub
 
CORRECTION: This is all of the code:

Private Sub cmdrptSearch_Click()
On Error GoTo Err_cmdrptSearch_Click
Dim stDocName As String
stDocName = "rptCACommunitySelfServe"
DoCmd.OpenReport stDocName, acPreview
Exit_cmdrptSearch_Click:
Exit Sub
Err_cmdrptSearch_Click:
MsgBox Err.Description
Resume Exit_cmdrptSearch_Click

End Sub
Private Sub cmdClear_Click()
Me.GroupName = Null
Me.firstName = Null
Me.lastName = Null
Me.EmailAddress = Null
End Sub
Private Sub cmdCloseReport_Click()
DoCmd.Close
End Sub
 
1. Will the end user have to close the report manually each time before entering new parameters?

That's how I usually handle this type of setup It doesn't have to be that way, but typically the report preview takes up most of the screen, so they would have to minimize to get back to your form anyhow.

2. If not, where is the Close Report command button? I could only find Close Form.

Docmd.Close when run from a report closes the report.

3. What's the code to create a command button to refresh the report?

I'm not sure that there is a refresh report as such. Typically you would close one report and then open the next.

4. Finally, can everything (preview report, clear entry, refresh data) be done using just 1 command button? Can't I add all the code I need behind one command?

I'm sure it could be, but that does not seem to be very intuitive to the end user. Maybe I am just not picturing it correctly.. Can you upload a stripped down version of your database?
 

Users who are viewing this thread

Back
Top Bottom