Full Version: Printing issue
UtterAccess Forums > Microsoft® Access > Access Forms
Grafixx01
Ok, so I just added a "Print" command button to my main form after designing all of the reports and subreports. The code below is what I put in. However, my issue is this, it prints ALL records and ALL data for those records.
That I need it to do is:
1. SAVE the current record.
2. PRINT ONLY THE CURRENT RECORD
3. RETURN the user to the MAIN MENU (frmMainMenu)
Any ideas?
Here's the code:
CODE
On Error GoTo Err_cmdPrintCurrent_Click
'this is the print command button to print the current task with all data on the form
    Dim stDocName As String
    Me.Refresh 'print current task on rptIndividual report with all data
    stDocName = "rptIndividual" 'print report
    DoCmd.OpenReport stDocName, acNormal
    DoCmd.Close acForm, "frmIndividual", acSaveYes
    stDocName = "frmMainMenu" 'open frmMainMenu upon correct login being entered
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    
Exit_cmdPrintCurrent_Click:
    Exit Sub
    
    
    
Err_cmdPrintCurrent_Click:
    MsgBox Err.Description
    Resume Exit_cmdPrintCurrent_Click
theDBguy
You'll need to add a criteria to your OpenReport statement to filter the data to the current record. For example:
oCmd.OpenReport stDocName, acNormal, , "[ID]=" & Me.ID
Hope that helps...
Grafixx01
Thanks DBguy!
After some thought, I figured out an alternative way to do it! In the rptIndividual record source on the report, I put in a query to just point back to the current record from the form Individual.
Looked like this: SELECT tblIndividual.* FROM tblIndividual WHERE (((tblIndividual.IndID)=Forms!frmIndividual!IndID));
Osmart am getting am I access at this stuff! (I am getting smart at this Access stuff I am!)
theDBguy
Happy to hear you got it fixed. Good luck with your project.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.