DoCmd.OpenReport problem

nosamlien

New member
Local time
Today, 12:35
Joined
Sep 24, 2008
Messages
4
Hi can anyone help? I'm moving a small number of users from Access 2000 up to Access 2007 in my office.
We have a shared database on a server which the new users on 2007 are having problems printing individual records from.
From within a form called 'Main' an option to print the current record on one of several standard reports is chosen. In this case onto a report called 'invoice'
A debug error pops up when I try to print which tells me that it can't find the 'main' table? I can't work this out as the code works fine on the old version but not in 2007 :mad:

The line is;

DoCmd.OpenReport "invoice", acViewNormal, "Main", "[contract number]=" & Forms!Main![Contract Number]

I've tried several different methods of altering the code such as;

DoCmd.OpenReport "invoice", acViewNormal, , "[contract number]=Forms!Main"

but this just prints out a blank 'invoice' with no record details from the 'Main' form.

Has anyone else had this problem when they've upgraded to 2007 ?, if so you help:confused:
 
You supply Main as a filter field , filter to what exactly ? just remove it or make sure main is selected as a record source if Main was a table assumingly present on your database
Now i wonder if MS Access 2000 didnt find a bug in there :)
 
Hi, thanks for the fast response!
'Main' is the name of the form from within which I'm trying to print the record.
Whilst in the form and on a certain record I've a toolbar that use to select the type of print output I want i.e. an 'invoice' or 'final invoicet' etc., depending on the template I want to use.
This then runs the code to output the single record from the form onto the correct report out to the printer. Like I said it still works fine in earlier versions of Access, but fails in 2007, with 'Runtime error '3011' and the message 'the... database engine can not find the object 'Main'. Make sure the object exists and you spell it's name and path name correctly'
 
nosurlien , please note that :

DoCmd.OpenReport "invoice", acViewNormal, "Main", "[contract number]=" & Forms!Main![Contract Number]

syntax mean the following :

"invoice" : report name

acViewNormal : report to open in print state

"Main" : filter similer to where condition , ie neglectable since you already have one (remove it)

"[contract number]=" & Forms!Main![Contract Number] : Your condition to meet (select contact number from report to print)

so your final syntax'd be :
DoCmd.OpenReport "invoice", acViewNormal, , "[contract number]=" & Forms!Main![Contract Number]

that'd be all.
 
Brilliant!!

Works perfect. I was was going nuts over this one!

My hero! Many thanks.
 
I dunno, but it worked somehow.
I was a bit worried that your solution would not be backward compatible with all my office machine but I've just exported the corrected module and imported into the other PCs just now and and it work on both old and new versions of Access ok.

Many thanks again!!!!
 

Users who are viewing this thread

Back
Top Bottom