Preview Report directly from form

Stephanie T.

Registered User.
Local time
Today, 00:48
Joined
Jun 20, 2002
Messages
60
I have a form where information is entered into one db. I would like a button on that form that would take the information being viewed at that moment to a report in Preview mode. I have already set up the report.

I have a button on the form that opens the report in Preview mode, but it allows access to all of the previous information input from other sessions. What I need is for each individual record to be an individual report.

Your input is greatly appreciated - Oh and we have yet to upgrade, I'm still in Access97 :rolleyes:

Thank you in advance,
Stephanie
 
Stephanie,

Search your Access 97 Help file for "open report" -- hopefully it will explain how to use the Where clause to filter your report down to the form's current record... Assume, for example, IDNum is filled with a unique value for each of your records and you have a textbox on your form bound to IDNum. You would then open your report doing something like this...
Code:
DoCmd.OpenReport "RptNames", acViewPreview, , IDNum = Me.IDNum

Regards,
Tim
 
Dear Tim,

Thank you for the help your suggestion does open the report, and but each form is not its own report. It makes all of the information in the underlying table into one report. It does not recognize any parameters for the report.

What I would like is to make it so that each form is its own report. And that report is created from the active form. I am wondering if I can change the code somehow to say "active". Here is my code:

DoCmd.OpenReport "rptSamples", acViewPreview, , RequestID = Me.RequestID

What if I changed it to something like this:

DoCmd.OpenReport "rptSamples", acViewPreview, , RequestID = Me.Current

Of course I did try that and the "method or data is not found", but it seems that I need to specify that only the "current" or "active" form should be viewed in a report.

The other absolutely useful option would be to simply export each form, individually, to MSWord. That is the ultimate goal with each individual report as well. But we don't want to have to sort through the other reports to see each individual one.

Any insight will be appreciated, I continue to decipher these huge books with lots of VBA code. Why can't this be in HTML that I understand.

Thanks again,
Stephanie
 
Steph:

First of all, you have to enclose the WHERE condition in quotes, such as:

"RequestID = Me.RequestID"

Second, is RequestID the primary key, and one displayed on the form? I have found that sometimes it helps to reference it explicitly as:

"RequestID = Forms!frmSamples!RequestID"

See if that helps.

SHADOW
 
Shadow --

You are a star!! That works!! Yes, the RequestID is the primary key and on the form. So, now when the button is pressed, a dialog box requests the RequestID and the report is that alone.

Perfect! My gratitude to you and Tim for your expert advice.

Whew! Now I can close these huge books and my eyes can stop rolling around in their sockets.

Best to you,
Stephanie :)
 
Steph:

You are a star!! That works!

Thank you for your kind words :)

the RequestID is the primary key and on the form. So, now when the button is pressed, a dialog box requests the RequestID and the report is that alone.

If you are referencing it correctly (as I showed), then it shouldn't be prompting you for the ID. If you zip the database (or a stripped down version with just the pertinent table(s), form(s) and report(s), I or someone else can probably tell you how to get it working without the prompt.

Perfect! My gratitude to you and Tim for your expert advice.

You are most welcome. I, and probably most people here have gleaned a LOT from this forum and are happy to give back a bit.

Good luck,

SHADOW
 
Shadow,

Hmm... well I don't know what I did, but as I was stripping down a version to upload, I fixed the problem. It now only opens the current report without asking for the RequestID. Yeah!!

Yes, the fabulous people on this forum have been amazing! What a great place to learn!!

Thanks!
Stephanie :D
 
You still have a problem. You need to save the current record before you open the report. The report gets its data from the table, NOT what is showing on the form so if this is a new record or you have changed it, the changed data will not yet have been saved to the table. So directly ahead of the OpenReport add:

DoCmd.RunCommand acCmdSaveRecord
 
Pat,

Again you come to my rescue. I didn't even know that I had a problem and you fixed it. Everything is great now!!

You're the best. Hope all is good with you.

Stephanie :)
 

Users who are viewing this thread

Back
Top Bottom