views:

1308

answers:

2

Sorry if this is a noob question, but I have been given the dubious honour of supporting an ancient legacy Access 2000 .adp application, written badly by someone years ago who is no longer around, when i have little experience with Access or VB myself :)

I have set up a WinXP dev machine with Access 2000 (it's an Access 2000 project) to do some support work. There is a pre-existing line of code which is supposed to print a report, which calls DoCmd.OpenReport with 6 arguments:

DoCmd.OpenReport ReportName, acViewPreview, , "orderId = 1234", , Printtype

When I run it I get a compile error: "Wrong number of arguments or invalid property assignment".

So I used 'intellisense' on DoCmd.OpenReport, and my access VB code editor tells me it is expecting only 4 arguments, not 6: ReportName, acViewNormal, FilterName and WhereCondition. When I go to the object browser for the command, the definition is:

Sub OpenReport(ReportName, [View As AcView = acViewNormal], [FilterName], [WhereCondition]) Member of Access.DoCmd (i.e. 4 args)

Looking on various posts on the web, some people seem to be passing 4 args, some 6. What gives? I'm guessing there are different versions of Access code libraries, and I have the wrong one. But I have no idea where to start resolving this. Anyone know Access and can help me out?

A: 

Just remove everything after the WhereCondition argument. The additional arguments are for later version of Access (they are for WindowMode and OpenArgs)

Steve
doesn't that suggest that perhaps the poster hasn't applied the latest service pascks for Access 2000 and the Jet engine?
Mitch Wheat
I installed all the latest service packs, this didnt resolve the issue. The problem was I needed Access XP (see accepted answer)
James Allen
Access XP or later, you mean.
David-W-Fenton
+1  A: 

In Access 2000, the OpenReport method accepted 4 parameters:

DoCmd.OpenReport reportname[, view][, filtername][, wherecondition]

where [, parameter] are optional.

In Access XP, OpenReport gained 2 more parameters to give:

DoCmd.OpenReport reportname[, view][, filtername][, wherecondition][, windowmode][, openargs]

Printtype is being used as an argument to the report and will need to be passed in using another method, e.g. read from the form field or public property.

Ajw
Yes, that's the answer, thank you! Installing Access XP instead of Access 2000 solved the problem. It's odd, it says in various window title bars that the project is Access 2000 format (thats why I isntalled Access 2000), yet the code is clearly targeted at Access XP.
James Allen
Ajw
@Ajw Actually the file format which makes a difference as to the size of the MDB file is Access 97 and older which were only 1 Gb. Access 2000 and hewer/Jet 4.0 support a 2 Gb file size.
Tony Toews
@James You can work with A2000 and A2002/A2003 format MDBs in Access 2003. However to make an MDE from an A2000 MDB you must be in A2000 or convert the MDB format to A2002/A2003.
Tony Toews
@Tony Toews: it's an ADP, so for MDB/MDE, read ADP/ADE.
David-W-Fenton
@Tony I used http://www.databasedev.co.uk/access_specifications.html to remind myself of the differences between 2000 and XP.
Ajw