Saving Form as Report

Krava

Registered User.
Local time
Today, 10:45
Joined
Jul 13, 2005
Messages
72
Hello all!

I would like to have one stupid question, because I could not find any answer on this forum.
I want save the Form as Report. I can do that from "Menu bar", but I want to do that from the code (VBA or Macro) without inputting the output parameters by users.
Do you have any idea how?

Many thanks.

Krava
 
Look up the RunCommand & acCmdSaveAsReport parameter in access help
 
Hi, Allan57!

Thank you for your response!

I have tried, but no success.
There is an Error msg from VBA: Runtime error '2046' : This Command is not available at the moment.


Do you have any idea?

Many thanks.

Krava
 
Hi Krava
It looks like certain RunCommand constants cannot be run from code started by an event on a form, the only other possible way of running the command is via a function which is then ran from a custom menu item.
Sorry about that
Allan
 
I don't understand why you would want to do such a thing from code. Once a form is saved as a report, what is the point of doing it again interactively?
 
Hi, Pat!

I said already that it is kind of stupid question.
Well, you are particulary right. I am trying to solve a different problem an it is to save a Form in SnapShot format, which works only with reports. I am not able to save a Form in snapshot format. Maybe only I do not know...
The idea was:
1) By setting the layout of the form by user- clicking on Export button
2) Saving the Form as Report called e.g. "TemporaryRpt"
3) Exporting the Report "TemporaryRpt" in snapshot format as defined by user
4) Deleting a Report "TemporaryRpt"

Kind of Crazy but I need to work it that way.

Thank you very much.

Krava
 
Your method isn't going to solve your problem which is probably that you need to print the data being displayed on the form. Forms are not optimized for printing. You are better off creating a report that is properly formatted. Use the where argument of the OpenReport method to restrict the data shown by the report. Don't forget to save the form's current record so that the report shows the most recent data.

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "Report Name",,,,"somefield = " & Me.somefield

Make sure that the number of comas is correct. I can't remember if there are 3 or 4 needed.
 
Hi, Pat!

We recently needed to get the Form to snapshot format file. I have talked to users and I found out we can manage it a different way.
Many thanks for your help anyways.

Krava
 

Users who are viewing this thread

Back
Top Bottom