Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Difference in subreport
Masih Ostad Novin 
     
2 years ago
Hi,
I want to display difference between 2 rows in a subreport, if there is any. If KS=CC2 and HS=CC1. The difference forecolor should be in red so only if KS or HS comes in second row I want red otherwise should it be in black. This is the code, but it doesn't work. See images. Thanks for any help.


Masih Ostad Novin OP  @Reply  
     
2 years ago

Masih Ostad Novin OP  @Reply  
     
2 years ago

Kevin Yip  @Reply  
     
2 years ago
Please clarify what "doesn't work."  Also, "Recordset" does not work for reports the way it does for forms, so you need another way to do this.  You can obtain the previous and current field values simply with the code below (see picture below).  Declare currentfieldvalue and previousfieldvalue as global variables.  Every time the Detail event runs, it moves to the next record automatically.  At the start of the Detail event, assign the field value to currentfieldvalue.  At the end of the Detail event, assign the field value to previousfieldvalue.  The next time the Detail event runs, previousfieldvalue will have the last record's field value, allowing you to compare the previous and current values, and take action accordingly.
Kevin Yip  @Reply  
     
2 years ago

Masih Ostad Novin OP  @Reply  
     
2 years ago
I changed the code. I try to use oldvalue property. I think this is a better method:

Private Sub Form_AfterUpdate()

  
    If Me!BufferType.OldValue <> Me!BufferType.Value Then
        MsgBox "The value has changed after the update.", vbInformation
    End If
    
End Sub

I tried also on controls AfterUpdate. Nothing happens. The MsgBox doesn't pop up.

Any idea!
Kevin Yip  @Reply  
     
2 years ago
Your code above is for forms.  Are we still dealing with reports here, like you said in your first post?  Oldvalue applies to user entries on a form, and has nothing to do with reports.
Masih Ostad Novin OP  @Reply  
     
2 years ago
This one was for a form.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/6/2026 7:42:31 AM. PLT: 0s