Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2007

Tip: Looking for answers? Try searching our database.

Me! pagesum = Me! RunSum - x   ??

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim in Spokane - 29 Jan 2007 18:44 GMT
What does the Me! do?

Found this on http://support.microsoft.com/?kbid=296249
The code works great.

Just curious about the Me! part.

Thanks
Jim
Douglas J. Steele - 29 Jan 2007 18:56 GMT
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.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> What does the Me! do?
>
[quoted text clipped - 5 lines]
> Thanks
> Jim
Jim in Spokane - 29 Jan 2007 19:24 GMT
Thanks! From what help file did you find that?

Jim

> From the Help file:
>
[quoted text clipped - 35 lines]
> > Thanks
> > Jim
Douglas J. Steele - 29 Jan 2007 20:03 GMT
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.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Thanks! From what help file did you find that?
>
[quoted text clipped - 45 lines]
>> > Thanks
>> > Jim
Jim in Spokane - 29 Jan 2007 19:43 GMT
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

> From the Help file:
>
[quoted text clipped - 35 lines]
> > Thanks
> > Jim
Douglas J. Steele - 29 Jan 2007 20:06 GMT
Did you remember to declare y as a Double, and to set y = 0 in the
ReportHeader_Print event?

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

>I modified the code from http://support.microsoft.com/?kbid=296249
> to sub-total a debit and credit column.
[quoted text clipped - 58 lines]
>> > Thanks
>> > Jim
Jim in Spokane - 29 Jan 2007 20:21 GMT
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

> Did you remember to declare y as a Double, and to set y = 0 in the
> ReportHeader_Print event?
[quoted text clipped - 61 lines]
> >> > Thanks
> >> > Jim
Jim in Spokane - 29 Jan 2007 20:24 GMT
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!

> Did you remember to declare y as a Double, and to set y = 0 in the
> ReportHeader_Print event?
[quoted text clipped - 61 lines]
> >> > Thanks
> >> > Jim
Jim in Spokane - 29 Jan 2007 21:11 GMT
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

> Actually, I think it was the missing y=0 that caused the problem.
>
[quoted text clipped - 73 lines]
> > >> > Thanks
> > >> > Jim
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.