Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Change to subroutine instead of a Function

18 views
Skip to first unread message

Momo4kids

unread,
Dec 9, 2009, 10:17:35 PM12/9/09
to
I am using a function that I found in Microsoft Support Article ID:
210350. It allows you to"Print a Constant Number of Lines Per
Group". The function works, but I want to change it to a subroutine
so I can call it multiple times under the OnPrint Property of a
report. When I change it to a subroutine, I get the following error
when I try to type the subroutine with it's parameters in the
Detail_Print event of the report. Compile error: Expected: =. Here
is the code I am using

under ReportHeader OnPrint =SetCount([Reports]!
[rptProjectEEClassAndCerts])

Function SetCount(R As Report)

TotCount = 0

End Function

Under Detail OnPrint [Event Procedure]
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
PrintLines(reports!rptProjectDailySignIn, totgrp, reports!
rptProjectDailySignIn!name) 'I get the error while typing this line

End Sub

Momo4kids

unread,
Dec 9, 2009, 10:19:36 PM12/9/09
to
>     PrintLines(reports!rptProjectDailySignIn, totgrp, reports!rptProjectDailySignIn!name) 'I get the error while typing this line
>
> End Sub

Oops....Heres the rest of the code

Public Sub PrintLines(R As Report, totgrp, f1 As Control )

TotCount = TotCount + 1

If TotCount = totgrp Then
R.NextRecord = False
ElseIf TotCount > totgrp And TotCount < 30 Then
R.NextRecord = False
f1.Visible = False


End If
End Sub

Any help is appreciated.

Salad

unread,
Dec 9, 2009, 10:57:11 PM12/9/09
to

Maybe use Call if it is working. As in
Call PrintToDebugWindow("Hello World")
or without "call" and no paranthesis
PrintToDebugWindow "Hello World"
Check help on Call.

Momo4kids

unread,
Dec 10, 2009, 12:16:00 AM12/10/09
to
> Check help on Call.- Hide quoted text -
>
> - Show quoted text -

I changed to the following:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Call PrintLines(reports!rptProjectDailySignIn, totgrp, reports!
rptProjectDailySignIn!name)

End Sub


The event will allow it without errors when I type it but I get this
error when I preview the report:
The express you entered has a function name that Microsoft Office
Access can't find.

Any other thoughts?


Salad

unread,
Dec 10, 2009, 12:31:55 AM12/10/09
to
You can compile the project? No errors when compiling?

Put the word
STOP
right abouve the Call line. Then step thru the code and see what the
parameters are that you are passing. Maybe passing Name, a reserved
word, upsets the code.


Momo4kids

unread,
Dec 10, 2009, 10:47:46 PM12/10/09
to
> word, upsets the code.- Hide quoted text -

>
> - Show quoted text -

I rewrote the subroutine under a new name and it is now working.
Thanks for the assistance

0 new messages