razoRjaw
10-08-2009, 07:02 PM
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.
A report is the best way to do that right?
HiTechCoach
10-08-2009, 08:34 PM
To answer your question from the post's title:
How to Print a Single Record from a Form in a Report (http://support.microsoft.com/default.aspx?scid=kb;en-us;209560)
If you are wanting to attacht he report to an email, you might be ab le to use Docmd.SendObject
razoRjaw
10-09-2009, 01:24 PM
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?
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
gemma-the-husky
10-10-2009, 01:14 AM
do this
strCriteria = "[CallID]=" & Me![CallID]
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