Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email report based on parameters entered from calendar form 1

Status
Not open for further replies.

bailey11

Technical User
Jan 18, 2005
103
US
I have a report that needs to be emailed. I have set the preview report button and print report button, with the criteria from a calendar. The criteria being the week ending date the users chooses.

The preview and print both work, but I can't find where to enter the criteria in code to email only the week ending. Is there a way other than choosing File....Send (as attachment), Snapshot format?

I don't want to explain that with each user (novice users).

THe code I used for the preview is:

Private Sub btnPreview_Click()
On Error GoTo Err_btnPreview_Click



Dim stDocName As String
Dim stLinkCriteria As String

Dim r As Form

stDocName = "RptBasicTImeEntryAudit"
stLinkCriteria = " WorkDate BETWEEN #" & Me.txtStartDate & "# AND #" & Me.txtEndDate & "#"
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria, , Me.txtEndDate
'Reports!QryTImeEntryAudit!PayPdEndDate = Me.txtEndDate.Value

Exit_btnPreview_Click:
Exit Sub

Err_btnPreview_Click:
MsgBox Err.Description
Resume Exit_btnPreview_Click

End Sub

Thanks Bailey11
 
You could edit the query that your report is based on so that it references the calendar form, rather than using link criteria. That is, add:
[tt]Between Forms!frmForm!txtStartDate And Forms!frmForm!txtEndDate[/tt]
To the criteria line for Workdate.
 
Thank you. I am a fairly novice code writer and didn't even think of that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top