Error in my code: tried to print to pdf using pdf printer on network

Error in my code: tried to print to pdf using pdf printer on network

am 18.01.2008 12:00:58 von Sietske

Hi all!

I already read a lot of earlier questions on this subject, but the
answers just didn't seem to help in my case. I hope one of you can
help me out:

Several persons will have access to my database. When they have added
the network pdf printer (called "PDFCreator") they should be able to
print single records as pdf documents. However, the button I've added
to make this possible, does not work. Literally, it contains the
following code:

'****************************

Private Sub btnPrintAlsPDF_Click()
On Error GoTo Err_btnPrintAlsPDF_Click

Dim strDocName As String
Dim strWhere As String
strDocName = "rptMyReport"
strWhere = "[Id_Record]=" & Me!Id_Record
DoCmd.OpenReport strDocName, acViewPreview, , strWhere
Application.Reports(strDocName).Printer =
Application.Printers("PDFCreator")

Exit_btnPrintAlsPDF_Click:
Exit Sub

Err_btnPrintAlsPDF_Click:
MsgBox Err.Description
Resume Exit_btnPrintAlsPDF_Click

End Sub

'****************************

The error occurs in the part Application.Printers("PDFCreator"). It
says "Ongeldige procedure-aanroep of ongeldig argument", which means
something like "invalid call for the procedure, or invalid argument".

Can somebody please tell me what is needed to fix this problem?

Re: Error in my code: tried to print to pdf using pdf printer on

am 18.01.2008 13:51:29 von Sietske

The other problem is solved too, now.
I simply replaced

Application.Reports(strDocName).Printer =3D
Application.Printers("NameOfMyNetworkPrinter")

with

Application.Reports(strDocName).Printer =3D
Printers("NameOfMyNetworkPrinter")

Now it works great.I've put it here, hoping that other people with the
same question can take advantage of it.

Bye!
Sietske


> Hi all!
>
> I already read a lot of earlier questions on this subject, but the
> answers just didn't seem to help in my case. I hope one of you can
> help me out:
>
> Several persons will have access to my database. When they have added
> the network pdf printer (called "PDFCreator") they should be able to
> print single records as pdf documents. However, the button I've added
> to make this possible, does not work. Literally, it contains the
> following code:
>
> '****************************
>
> Private Sub btnPrintAlsPDF_Click()
> On Error GoTo Err_btnPrintAlsPDF_Click
>
> =A0 =A0 Dim strDocName As String
> =A0 =A0 Dim strWhere As String
> =A0 =A0 strDocName =3D "rptMyReport"
> =A0 =A0 strWhere =3D "[Id_Record]=3D" & Me!Id_Record
> =A0 =A0 DoCmd.OpenReport strDocName, acViewPreview, , strWhere
> =A0 =A0 Application.Reports(strDocName).Printer =3D
> Application.Printers("PDFCreator")
>
> Exit_btnPrintAlsPDF_Click:
> =A0 =A0 Exit Sub
>
> Err_btnPrintAlsPDF_Click:
> =A0 =A0 MsgBox Err.Description
> =A0 =A0 Resume Exit_btnPrintAlsPDF_Click
>
> End Sub
>
> '****************************
>
> The error occurs in the part Application.Printers("PDFCreator"). It
> says "Ongeldige procedure-aanroep of ongeldig argument", which means
> something like "invalid call for the procedure, or invalid argument".
>
> Can somebody please tell me what is needed to fix this problem?

Re: Error in my code: tried to print to pdf using pdf printer on network

am 19.01.2008 06:54:49 von Tom van Stiphout

On Fri, 18 Jan 2008 04:51:29 -0800 (PST), Sietske
wrote:

>The other problem is solved too, now.
>I simply replaced
>
>Application.Reports(strDocName).Printer =
>Application.Printers("NameOfMyNetworkPrinter")
>
>with
>
>Application.Reports(strDocName).Printer =
>Printers("NameOfMyNetworkPrinter")
>
>Now it works great.I've put it here, hoping that other people with the
>same question can take advantage of it.
>
>Bye!
>Sietske
>
>
>> Hi all!
>>
>> I already read a lot of earlier questions on this subject, but the
>> answers just didn't seem to help in my case. I hope one of you can
>> help me out:
>>
>> Several persons will have access to my database. When they have added
>> the network pdf printer (called "PDFCreator") they should be able to
>> print single records as pdf documents. However, the button I've added
>> to make this possible, does not work. Literally, it contains the
>> following code:
>>
>> '****************************
>>
>> Private Sub btnPrintAlsPDF_Click()
>> On Error GoTo Err_btnPrintAlsPDF_Click
>>
>>     Dim strDocName As String
>>     Dim strWhere As String
>>     strDocName = "rptMyReport"
>>     strWhere = "[Id_Record]=" & Me!Id_Record
>>     DoCmd.OpenReport strDocName, acViewPreview, , strWhere
>>     Application.Reports(strDocName).Printer =
>> Application.Printers("PDFCreator")
>>
>> Exit_btnPrintAlsPDF_Click:
>>     Exit Sub
>>
>> Err_btnPrintAlsPDF_Click:
>>     MsgBox Err.Description
>>     Resume Exit_btnPrintAlsPDF_Click
>>
>> End Sub
>>
>> '****************************
>>
>> The error occurs in the part Application.Printers("PDFCreator"). It
>> says "Ongeldige procedure-aanroep of ongeldig argument", which means
>> something like "invalid call for the procedure, or invalid argument".
>>
>> Can somebody please tell me what is needed to fix this problem?

Re: Error in my code: tried to print to pdf using pdf printer on network

am 19.01.2008 07:01:46 von Tom van Stiphout

On Fri, 18 Jan 2008 04:51:29 -0800 (PST), Sietske
wrote:

It's great that you fixed it, but I'm left with WHY?
Essentially you replaced "Application.Printers" with "Printers".
Printers is a collection in the Application object, so the two
statements should be equivalent,. Why aren't they?

If an object is not fully qualified (e.g. "Recordset" vs.
ADODB.Recordset or DAO.Recordset) it matters in which order the
References (code window > Tools > References) are listed, but that
seems an obscure problem - most users just taking the default.

Not sure what to think of this.

Btw, I love your name Sietske. Brings back memories.

-Tom.



>The other problem is solved too, now.
>I simply replaced
>
>Application.Reports(strDocName).Printer =
>Application.Printers("NameOfMyNetworkPrinter")
>
>with
>
>Application.Reports(strDocName).Printer =
>Printers("NameOfMyNetworkPrinter")
>
>Now it works great.I've put it here, hoping that other people with the
>same question can take advantage of it.
>
>Bye!
>Sietske
>
>
>> Hi all!
>>
>> I already read a lot of earlier questions on this subject, but the
>> answers just didn't seem to help in my case. I hope one of you can
>> help me out:
>>
>> Several persons will have access to my database. When they have added
>> the network pdf printer (called "PDFCreator") they should be able to
>> print single records as pdf documents. However, the button I've added
>> to make this possible, does not work. Literally, it contains the
>> following code:
>>
>> '****************************
>>
>> Private Sub btnPrintAlsPDF_Click()
>> On Error GoTo Err_btnPrintAlsPDF_Click
>>
>>     Dim strDocName As String
>>     Dim strWhere As String
>>     strDocName = "rptMyReport"
>>     strWhere = "[Id_Record]=" & Me!Id_Record
>>     DoCmd.OpenReport strDocName, acViewPreview, , strWhere
>>     Application.Reports(strDocName).Printer =
>> Application.Printers("PDFCreator")
>>
>> Exit_btnPrintAlsPDF_Click:
>>     Exit Sub
>>
>> Err_btnPrintAlsPDF_Click:
>>     MsgBox Err.Description
>>     Resume Exit_btnPrintAlsPDF_Click
>>
>> End Sub
>>
>> '****************************
>>
>> The error occurs in the part Application.Printers("PDFCreator"). It
>> says "Ongeldige procedure-aanroep of ongeldig argument", which means
>> something like "invalid call for the procedure, or invalid argument".
>>
>> Can somebody please tell me what is needed to fix this problem?