Printing Specific Reports

  • Thread starter Thread starter Henry Lello
  • Start date Start date
H

Henry Lello

Hello all,

I am new to Access development so am probably asking a
rather obvious question.

I want to create a button that would print a report
specific to the current record open in a form.

I realise the openreport function within a macro is the
way to do it but I cannot work out what the where
condition should be.

Because there is more than one query that can bring me to
each record I cannot rely on a query based report.

Can anyone help?
 
In the code behind the print report command button try
changing it to something like this

Dim stDoc As String
Dim stWhere As String
stDoc = "nameof report"
stWhere = "primarykeyfield = " & Me.primarykeytextbox
DoCmd.OpenReport stDoc, acViewPreview, , stWhere

Jim
 
I've got the same problem and have tried similar code that is posted here. It still won't work. The person who developed some of the reports in our database is no longer available and his code doesn't even have the WHERE portion after acViewPreview. Any suggestions would be appreciated.

Did the code posted by Jim/Chris work for you Henry

This block of code works in older forms generated by someone else. It is also what the report wizard gives. But when I use either I only get the first record not the one I'm on

Dim stDocName As Strin
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70 'refres
DoCmd.Minimiz
stDocName = "Assistant Diaries Report
DoCmd.OpenReport stDocName, acPreview 'previe

This is the block of code I'm trying to use. I've tried using acViewPreview and a bunch of other syntaxes. Nothing seems to work

Dim stDocName As Strin
stDocName = "rptAsstDiaries
stWHERE = Me.fAsstDiaryID
DoCmd.OpenReport stDocName, acPreview, , "[fAsstDiaryID] = " & stWHERE
 
Back
Top