Enter Parameter Value - why?

Ramzess II

Registered User.
Local time
Today, 02:55
Joined
Apr 7, 2004
Messages
32
Hello!

I put this code:

Code:
Private Sub Command40_Click()
Dim Filtrs As String
Dim Copies As Integer
Dim RepName As String

Filtrs = "(((tblSchools.schID)=" & CLng(Me![schID]) & "))"
Copies = Me.psbPostersCnt
RepName = "rptPosters"

DoCmd.OpenReport RepName, acViewPreview, Filtrs, "(((tblSchools.schID)=" & CLng(Me![schID]) & "))"
DoCmd.PrintOut acPrintAll, , , , Copies
DoCmd.Close acReport, "rptPosters"

End Sub

in my form to print out a pre-defined number of copies (Copies) of the current record in the form (Filtrs). Form is based on a query which is made up from two tables where one of them contains "schID" field which as well is included in this query.

BUT when I press the button on the form it does not print out the defined number of copies of current record but actually asks me to "Enter Parameter Value" for "schID" field and when I enter this ID number it goes printing ALL records available!

What could be the reason? Could anyone help me please?

I attached this db file as well. It is in Access 2000 format.
the form where the button is is called "frmPossibleInput" and report which is used for printing is called "rptPosters"
 

Attachments

There are easier ways to do this, either base the Report on a parameter query and just reference the field on the form, or use something like

DoCmd.OpenReport RepName, acViewPreview, , "[schID]=" & Me![schID]
DoCmd.PrintOut acPrintAll, , , , Copies
DoCmd.Close acReport, "rptPosters"

End Sub
 
Rich, it still asks me to enter this schID value as I press the button on my form.

Now I reduced the code to this:

Code:
Dim Copies As Integer
Dim RepName As String

Copies = Me.psbPostersCnt
RepName = "rptPosters"

DoCmd.OpenReport RepName, acViewPreview, , "[schID]=" & Me![schID]
DoCmd.PrintOut acPrintAll, , , , Copies
DoCmd.Close acReport, "rptPosters"

:(
 
You see Rich, the actual reason why I need this code is to print the defined number of posters for each record I have in this form.
Though since it is possible that for some records it is not necessary to print posters, at this stage I open the form, go to the record for which I need to print posters, click on the button, then go next record I need and so on and on.
Well actually before that I used to click this button so many times as many posters I need to print for each record.
Now I decided that I could put a text field which represents the number, and that the code takes this number as a number of copies, so I need to click the button just once.
I know that it may sound stupid, but I really don't know access programming so good I could find a better way to do it. :(

That is why I really appreciate that there is such forum where you can search for an answer and if needed ask you - smart guys! :)
 
Then schID is not a valid field either in the Form or its underlying recordset.
I don't have Access 2000, if you want me to take a look you'll have to post a 97ver
 

Users who are viewing this thread

Back
Top Bottom