Your code portion looks a little ambiguous. You're assigning a value to strCriteria that's assigning a value to [claimID] and that won't work. Assign the value of your form's [claimID] field to strCriteria and then open the report using strCriteria as the criteria or open it using the open forms [claimID] field as the criteria:
Firstly - I tried adding to the Conditions but that doesn't work - I get a printout of all records.
The code below is attached to an open report button - This works great and opens the report with the correct ID.
Code:
Private Sub Command391_Click()
On Error GoTo Err_Command391_Click
Dim strCriteria As String
Dim stDocName As String
strCriteria = "[claimID]=Forms!frmClaimsParts!claimID"
stDocName = "rptParts"
DoCmd.OpenReport stDocName, acPreview, , strCriteria
Exit_Command391_Click:
Exit Sub
Err_Command391_Click:
MsgBox Err.Description
Resume Exit_Command391_Click
End Sub
Ok - Now what I need to actually do is to send report to file in pdf format - no problem in access2007 you would think - Except the button to Report to File is not selective - I am getting all records.
So - What i would like is to use the embedded macro code as VBA so I can correctly send just the current record to file.
The embedded macro reads...
Action (Output To)
Arguments
Report, rptParts, PDF Format (*.pdf), , Yes, , 0, Print
Also - for some reason the embedded macro won't give the option to save as a module.
that wont work you need to base the report off a query on the table, not the table itself, you can filter form but not tables. create a query and set the criteria as Forms!frmClaimsParts!claimID
Thanks all - I have it - Remembering i'm using Access 2007 - I have the query set to open just the report that relates to the passed ID as above - Also I have the report filtered with the same criteria - and set the filter to run OnLoad=Yes - This takes care of the report to file(pdf) to just the record we are working on.