Re: code help (RobDog888)
The object oCnn has not be declared (or initialised!). You should generally either use DAO (your db variable) or ADO (your oRs variable), but not both.
For an example of setting up an ADO connection, see the ADO Tutorial link in my siganture.
Oh, and the VBCode tags on this forum need to be like this:
[vbcode]code here[/vbcode]
Re: code help (RobDog888)
OK. thanks for your help. But, now I'm getting an error message in the crvMyCRViewer line of the code. It says variable not defined. How do I declare this variable so that I can use the viewer?
Re: code help (RobDog888)
That would be a control, which needs to be added to your form (presumably called "CRViewer" in the toolbox, which you should call "crvMyCRViewer" when you put it on your form).
If the control isn't in your toolbox, you will need to go to "Project"->"Components", and select it from the list.
Re: code help (RobDog888)
I'm sorry to sound so stupid, but the form you're referring to is an Access form? As of right now, I'm not using a form of any kind. I'm simply trying to build the code to preview the report. Can that be done?
Re: code help (RobDog888)
Yes, that is the kind of form I meant. I don't know if you can preview a report without the control (I've never tried), so you may have to add a hidden form with the control on it (in which case you could use formname.crvMyCRViewer).
This thread shows how to print without the control (in your case, oReport.Printout False) but not how to preview it. There may be some kind of preview option - just see what Methods the oReport object provides.
Re: code help (RobDog888)
AFAIK, since I have only used CR 8.5 Developer, you ccan not preview a report without the CR Viewer control as that is what it was mean to be used for.
You could Export the report to a pdf or something and then open it via code but then the report has all its data in the file. so if a refresh or change is needed you will need to re-Export it and open it again. Bot too professional looking but it doesnt use the Viewer control that way.