Hi Ray
You would place your code behind an action
When you use DoCmd.OpenReport there are a number of other “things” that
you need to tell access so that you can open the report as you want.
You command will look some thing like this
DoCmd.OpenReport "", ,, "",
Which does (I admit) look a bit strange. Basically in between all the "",,,
is where you put the items that you want to include (or exclude) from the
report, how want it to look, etc.
So have a go on a COPY of your DB and see what happens. Use something like
this
DoCmd.OpenReport "NameOfReport", acViewPreview, "FilterOrQuery", "WHERE
statement", acNormal
What does all this mean??
DoCmd.OpenReport This tell access to open a report
NameOfReport This is self explanatory
acViewPreview You could also have acViewPrint, etc
FilterOrQuery If you want the report to be filtered by a Query (or by a
Filter you have saved as a Query) enter the name here.
WHERE statement You don’t “have” to use a query to filter your report you
can use a WHERE statement (even though you “DON’T use the the word “Where"
which is a bit mad I know)
This would be something like
[PaymentDate]=[Forms]![frmAccounts]![frmClientAccounts].[Form]![PaymentDate]
This is where the [PaymentDate] on the Report is equal the [PaymentDate] on
the SubForm [ClientAccounts] of the main form [frmAccounts]
acNormal is the WindowMode (what type of window the report will open in)
All of the above would be written like this
DoCmd.OpenReport "rptAuditUKOPfile", acViewPreview, "qryBookings",
"[PaymentDate]=[Forms]![frmAccounts]![frmClientAccounts].[Form]![PaymentDate]", acNormal
Someone else will answer you as well I’m sure with a more detailed (and
simpler to understand) answer as English isn’t may 1st language, but in the
meantime I hope this helps

Signature
Wayne
Manchester, England.
> I need to print a report from VB but I can not find any referenc to a command
> in any of my books. Is there such a command that I am missing here? (there
> must be)
> Thanks Ray C
Ray C - 31 Jul 2006 09:42 GMT
Hi Wayne
Thank you for your comprehensive response. However, I need to try and
understand Reports better. I am reasonably OK with Forms and can achieve all
I currently need to do in a Form but I need to Print out the information
collected within the form (presumably ) through Reports. Your code helps me
print out the Report that I have designed rather than just View it (when I
look up acViewPrint in Help, it says the only option I have is acViewpreview)
and that is great but I can not get the Report to populate with any
information.
The Form I am using is used to book out some equipment on hire and gathers
all of the Customers details from the Customers Table, details from the
Contracts Table and stock from trhe Stock Table (all linked by Contract
number. Because there can be more than one item of Stock being allocated to a
Contract, that information id displayed in a Sub Form. Within Forms, this is
all OK. However, I want to print this information and use it as a Schedule to
the Contract. At least I can get the Form to Print now but it is doing my
head in trying to get the Report to contain the same data that I have already
collected in my form.
Could you suggest any documentation that might help me get over this firs
(and very basic ) hurdle?
Thanks Ray C
> Hi Ray
>
[quoted text clipped - 49 lines]
> > must be)
> > Thanks Ray C