Me! pagesum = Me! RunSum - x ??

D

Douglas J. Steele

From the Help file:

<quote>
The Me keyword behaves like an implicitly declared variable. It is
automatically available to every procedure in a class module. When a class
can have more than one instance, Me provides a way to refer to the specific
instance of the class where the code is executing. Using Me is particularly
useful for passing information about the currently executing instance of a
class to a procedure in another module. For example, suppose you have the
following procedure in a module:

Sub ChangeFormColor(FormName As Form)
FormName.BackColor = RGB(Rnd * 256, Rnd * 256, Rnd * 256)
End Sub

You can call this procedure and pass the current instance of the Form class
as an argument using the following statement:

ChangeFormColor Me
</quote>

In other words, in a form's module, it's a way of referring to the current
form. You could have used:

Forms!NameOfForm!PageSum = Forms!NameOfForm!RunSum - x
x = Forms!NameOfForm!RunSum

but if you'd had two copies of NameOfForm open, you'd have run into
problems.
 
J

Jim in Spokane

I modified the code from http://support.microsoft.com/?kbid=296249
to sub-total a debit and credit column.

Wondering after reading your reply if this code is okay?
The values I see for the Credit column in Report View are correct, but when
it prints, there are different values. As I scroll through the pages front
to back and then back to front, the numbers change in Report View.

Any ideas?

Me!pagesum = Me!RunSum - x
Me!pagesumcr = Me!RunSumCR - y
x = Me!RunSum
y = Me!RunSumCR
 
D

Douglas J. Steele

Well, I pulled it from the Access 97 Help file, but I'd expect to find it in
other versions as well.

You might have to go into the VB Editor before you look for it, though: you
get different help in the two places.
 
D

Douglas J. Steele

Did you remember to declare y as a Double, and to set y = 0 in the
ReportHeader_Print event?
 
J

Jim in Spokane

When I took the Me! off the second column add for CR, got stable numbers.

Dim x As Double
Dim y As Double

Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer)
Me!pagesum = Me!RunSum - x
pagesumcr = RunSumCR - y
x = Me!RunSum
y = RunSumCR
End Sub

Private Sub ReportHeader_Print(Cancel As Integer, PrintCount As Integer)
x = 0
y = 0
End Sub
 
J

Jim in Spokane

Actually, I think it was the missing y=0 that caused the problem.

This works too.
Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer)
Me!pagesum = Me!RunSum - x
Me!pagesumcr = Me!RunSumCR - y
x = Me!RunSum
y = Me!RunSumCR
End Sub

Thanks!
 
J

Jim in Spokane

Tested this on another database and had to remove the Me! from the credit
column to get stable numbers.

Dim x As Double
Dim y As Double

Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer)
Me!pagesum = Me!RunSum - x
pagesumcr = RunSumCR - y
x = Me!RunSum
y = RunSumCR
End Sub
Private Sub ReportHeader_Print(Cancel As Integer, PrintCount As Integer)
x = 0
y = 0
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top