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
--
Wayne
Manchester, England.
Ray C said:
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