report that shows only one record

razoRjaw

Registered User.
Local time
Today, 04:46
Joined
Sep 16, 2009
Messages
17
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?
 
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
 
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
 

Users who are viewing this thread

Back
Top Bottom