projektx
03-02-2005, 02:31 AM
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:
Ukraine82
03-02-2005, 05:09 AM
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
projektx
03-05-2005, 10:44 PM
thanks for thge reply. But it keeps telling me that the syntax is wrong.
WayneRyan
03-05-2005, 10:55 PM
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
axsnub
05-26-2005, 04:31 PM
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.