Printing a record through reports

projektx

New member
Local time
Today, 15:48
Joined
Mar 2, 2005
Messages
6
Hi, I am new to this forum and i have had a bit of a look around but can't really make out an answer to my question.

I have a problem. I made a small database for the company i work for to manage job cards.

I made a button through the wizard to print a report from a form but instead of printing just the record that is on the form, it prints every record from the table the form data comes from. How can i modify this so that it just prints the record that is on the form at that time?

Help pleaz :mad:
 
If you wish to print a current record from a form to a report. Paste this code on a command button (On Click Event).

Dim strDocName As String
Dim strLinkCriteria As String

strDocName = "YourReportName"
strLinkCriteria = "[YourFieldName] = Forms![YourFormName]![YourFieldName]"

DoCmd.OpenReport strDocName, acNormal, , strLinkCriteria


hth,
Michael
 
thanks for thge reply. But it keeps telling me that the syntax is wrong.
 
projektx,

For a string, number and date:

DoCmd.OpenReport "YourReport",,,"SomeKeyField = '" & Me.SomeKeyField & "'"
DoCmd.OpenReport "YourReport",,,"SomeKeyField = " & Me.SomeKeyField
DoCmd.OpenReport "YourReport",,,"SomeKeyField = #" & Me.SomeKeyField & "#"

Wayne
 
Ukraine82 said:
If you wish to print a current record from a form to a report. Paste this code on a command button (On Click Event).

Dim strDocName As String
Dim strLinkCriteria As String

strDocName = "YourReportName"
strLinkCriteria = "[YourFieldName] = Forms![YourFormName]![YourFieldName]"

DoCmd.OpenReport strDocName, acNormal, , strLinkCriteria


hth,
Michael

With this code do you need a line for every field in your form? I have about 100 fields in my form and if this is how it's done than that's okay but if there is a faster way I would love to know.
 

Users who are viewing this thread

Back
Top Bottom