Results 1 to 30 of 30

Thread: [RESOLVED] Help!!! To Format The Access Report

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    260

    Resolved [RESOLVED] Help!!! To Format The Access Report

    Dear friends

    I am creating a report in which i want that the data should be formated according to some condition. for example

    if date of joining of a person is more than 20 years of date of birth, Date of joining should be displayed in green, if date of joining is more than 25 year of date of birth then date of joining should be displayed in yellow color.

    I do not know how to do it in ms Access. Kindly help me regarding that.

    plz help!!! its urgent


    Thansk in advance


    shivpreet2k1

  2. #2
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Help!!! To Format The Access Report

    Hi,,,

    Use the conditional formatting property of a control...

    In the design view of the report ,right click on a control (i.e textbox)..Choose conditional formatting then
    apply a certain criteria for it...Then select the appropriate font color inside the conditional formatting box...

    Inform me if this works...


  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    260

    Re: Help!!! To Format The Access Report

    Hi Friend

    Thnx for help but i already tried for this. may be i am wrong on some part that it should check the data of the other field lke if i want to format the date of joining, this field first of all compare itself with the field date of birth in the same record and if there is any difference according to the condition then it should display the different color.

    Kindly provide help on this.

    Thanks in advance

    Shivpreet2k1

  4. #4
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Help!!! To Format The Access Report

    may be i am wrong on some part that it should check the data of the other field lke if i want to format the date of joining, this field first of all compare itself with the field date of birth in the same record
    Hi,

    Are you saying that your comparing two fields 1) dateofbirth
    2)datejoining? Say, if dateofjoining field is more than 20 years of date of birth, the dateofjoining field should be displayed yellow?

    Am I correct on this?


  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    260

    Re: Help!!! To Format The Access Report

    Hi friend

    Yes u r right. I m comparing two fields.


    Shivpreet2k1

  6. #6
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Help!!! To Format The Access Report

    Hi,

    if date of joining of a person is more than 20 years of date of birth, Date of joining should be displayed in green, if date of joining is more than 25 year of date of birth then date of joining should be displayed in yellow color.
    I suggest that the condition should be more specific...I say the result date is
    26 based from dateofbirth and datejoin...Since 26 is greater than 20 and greater than 25, what should be done?

    This is my suggestion for the condition...

    Algorithm:

    Code:
    If result > 20 and <= 25 then
        font color is green
    else  'this if for result greater than 25
        font color is yellow
    end if
    Hope my suggestion is fine with you....
    Last edited by KGComputers; Mar 6th, 2006 at 03:09 AM.

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Help!!! To Format The Access Report

    You can also easily format an Access report in the report class file like so.
    VB Code:
    1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    2.     Text1.Properties.Item(25) = 255 'RED
    3. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Help!!! To Format The Access Report

    VB Code:
    1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    2.     Text1.Properties.Item(25) = 255 'RED
    3. End Sub

    Hi!

    where does .item(25) referred to? Is this referred to the font color?
    Im new with this code....


    Can this code be applicable in his requirements? His requirements have some certain criteria? I mean condition...


  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Help!!! To Format The Access Report

    Right, I was only showing how to change the font color dynamically when the report is being generated.

    The Properties.Item(25) refers to the textbox objects forecolor property.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    260

    Re: Help!!! To Format The Access Report

    hi robdog


    thnx for ur help. just one more question. how can i acess the text property of textbox in the report.

    Plz help its urgent.

    Thanks again buddy

    Shivpreet2k1

  11. #11
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Help!!! To Format The Access Report

    Hi RD,

    I tried to apply this code...However the label is now being underlined not changing the forecolor...

    VB Code:
    1. Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
    2.     Label9.Properties.Item(25) = 255
    3.     Label10.Properties.Item(25) = 266
    4. End Sub
    I also tried the code in your post however it does not change the forecolor..

    VB Code:
    1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    2.     txtname.Properties.Item(25) = 255 'RED
    3. End Sub


    Thanks...
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    260

    Re: Help!!! To Format The Access Report

    Dear Friend

    Use this code in report open event . it is working. ihave cheked it.

    Tks

    Shivpreet2k1

  13. #13
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Help!!! To Format The Access Report

    Hi...

    Can you post your code...

    Thanks...

    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Help!!! To Format The Access Report

    Item 25 is only for the textbox forecolor. If you use a different control then the forecolor property will be a different number. I think you can use the items names but dont have time to test it.
    Just do a Debug.Print Label9.Properties.Item(0).Name while placing a breakpoint to stop the code execution. When you find the item number that corresponds to the property you want then use that number, that is if the actual property names dont work.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Help!!! To Format The Access Report

    Hi RD,

    I'll give it a spin...

    Thanks...
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  16. #16
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Help!!! To Format The Access Report

    HI RD,

    Thanks for the idea....

    Maybe i'll be comfortable with the property names rather than the numbers..Works fine for me...

    VB Code:
    1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    2.      datejoin.Properties.Item("ForeColor") = 255
    3. End Sub

    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  17. #17
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Help!!! To Format The Access Report

    Yes, I wasnt sure if it worked with the names. Its been a while since I did formatting on an Acces report. Property names are more easier to follow.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  18. #18
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Help!!! To Format The Access Report

    Property names are more easier to follow
    I agree.....
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  19. #19

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    260

    Re: Help!!! To Format The Access Report

    Hi kgcomputers

    Tahnk for ur help but. i want to access text of the date datafield which property i should use. I have used text property but it gives me error.

    what is the problem in this code.

    MsgBox [Date].Properties.Item("text")

    plz help its urgent.


    Thanks in advance

    Shivpreet2k1

  20. #20
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Help!!! To Format The Access Report

    MsgBox [Date].Properties.Item("text")
    Hi...

    What is the error of the code?

    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  21. #21

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    260

    Re: Help!!! To Format The Access Report

    Dear friend
    i wanna see and compare the data in access report but i am not able ot

    try to run urself the code in the report open event and see it and if u find solution. kindly inform me. i wam waiting.

    Thanks

    Shivpreet2k1

  22. #22
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Help!!! To Format The Access Report

    If your control is named [Date] then rename it as the reserved word may still be giving issues evven with the brackets.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  23. #23
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Help!!! To Format The Access Report

    If your control is named [Date] then rename it as the reserved word may still be giving issues evven with the brackets.
    It may be a cause....Try substituting the name with txtDate...

    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  24. #24

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    260

    Re: Help!!! To Format The Access Report

    Dear Friend

    I have tried it but it still not working. cOul u provide me ur code.


    thnx

    Shivpreet2k1

  25. #25
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Help!!! To Format The Access Report

    Are you placing the code in the Detail_Format section or ? Can you post your code as that would be more relevant.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  26. #26
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Help!!! To Format The Access Report

    What are the modifications you made through the code? Post your code please....
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  27. #27

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    260

    Resolved Re: Help!!! To Format The Access Report

    Hi Kg and rob dog


    Got it boss. Pronlem has been solved . I m placing some sample coe so that it could help other new bies also.

    VB Code


    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    On Error Resume Next



    VB Code:
    1. 'document in custom formatting
    2. If IsDate([Date].Properties.Item("Text")) = True Then
    3.  
    4.    [Document_in_Custom].Properties.Item("BackStyle") = 1
    5.     [Document_in_Custom].Properties.Item("backcolor") = 16777215
    6. Else
    7.    
    8.     If DateDiff("D", [Date].Properties.Item("Text"), Now) > 4 Then
    9.         If IsDate([Document_in_Custom].Properties.Item("Text")) = False Then
    10.             [Document_in_Custom].Properties.Item("BackStyle") = 1
    11.             [Document_in_Custom].Properties.Item("backcolor") = 255
    12.         End If
    13.     Else
    14.         If DateDiff("D", [Date].Properties.Item("Text"), Now) > 2 And DateDiff("D", [Date].Properties.Item("Text"), Now) <= 4 Then
    15.             If IsDate([Document_in_Custom].Properties.Item("Text")) = False Then
    16.                 [Document_in_Custom].Properties.Item("BackStyle") = 1
    17.                 [Document_in_Custom].Properties.Item("backcolor") = 65535
    18.             End If
    19.         End If
    20.     End If
    21.   End If
    22.  
    23. End sub

    _____

    Thanks friends


    shivpreet2k1
    Last edited by RobDog888; Mar 10th, 2006 at 01:24 AM. Reason: Added [vbcode] tags

  28. #28
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Help!!! To Format The Access Report

    Glad to hear it

    Ps, in order to let others know its resolved, click on the thread tools menu and select "Mark Thread as Resolved" so its viewable from the forum level view.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  29. #29
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: [RESOLVED] Help!!! To Format The Access Report

    Your Welcome and Good job....
    One last thing, please put VB code tags in your code so that it would be more readable...

    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  30. #30
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] Help!!! To Format The Access Report

    Added [vbcode] tags.

    I got it for him.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width