How can I create a report that shows ONLY the record currently viewed on my form?
I want to make a cmd button to email out only the currently selected record.
Yes thanks, that is exactly what I want.
One slight hitch in the code which was built for Nwind is relying on a primary key for a string. my table has a CallID primary key of type autonumber and throws back a type mismatch
why doesn't the autonumber work as a string? should i change it to Dim as Autonumber?
Code:
Private Sub cmdPrint_Click()
Dim strReportName As String
Dim strCriteria As String
strReportName = "rptNewCall"
strCriteria = "[CallID]='" & Me![CallID] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
End Sub
basically the criteria has to be masked with certain characters depending on its type
text - " or ' characters
field = "Fred" or
field = Fred
number - no characters
field = 12
date # characters
field = #12/03/09#
in this latter case you have to be careful if not in US. ie
US date is December 3rd
UK date is 12th March
in some cases access/sql will try to treat the date as US format, and if you dont want that, you have to be aware of this possiblilty, and be more explicit in describing the date