Results 1 to 12 of 12
  1. #1
    Join Date
    Dec 2002
    Posts
    97

    Red face Unanswered: Detail Properties control

    I'm trying to set the backcolor of my detail section based the value of a field in the report.

    Here's my current code.

    dim rpt as Report, clrLtGrey as Long

    Set rpt = Reports![rptCurrent]

    clrLtGrey = 15263976


    If rpt![myField] Is Null Then

    rpt.Section(acDetail).BackColor = clrLtGrey
    Else
    rpt.Section(acDetail).BackColor = clrLtGrey
    End If

    It's not likin' it. Any suggestions?

    -C

  2. #2
    Join Date
    Dec 2002
    Posts
    97

    Exclamation I forgot

    The code still doesn't work but I forgot to include these values in the previous code. So here's what it "really" looks like.


    Dim rpt As Report
    Dim clrWhite As Long, clrLtGrey As Long

    clrWhite = 16777215
    clrLtGrey = 15263976

    Set rpt = Reports![rptCurrent]

    If rpt![myField] Is Null Then

    rpt.Section(acDetail).BackColor = clrLtGrey

    Else
    rpt.Section(acDetail).BackColor = clrWhite

    End


    Thanks again.
    -C

  3. #3
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580

    Lightbulb Where is the code?

    Which event is the code behind?

    Don't think you can do this unless the report is first opened in design view, changed and then opened in print preview view.

  4. #4
    Join Date
    Dec 2002
    Posts
    97

    Run bbehind

    Currently the code is running in the detail section On Format.

    -C

  5. #5
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    are you trying to do condiononal formating? if so add a second copy of myField to the report then set the condional formating to that the textbox color and the writing are grey when the field is null (with the defaults set to white,white) and then size to to fill the detail
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  6. #6
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    heres an examlple of what i mean
    Attached Files Attached Files
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  7. #7
    Join Date
    Dec 2002
    Posts
    97

    Text Box

    Unfortunately, no, that's not what I'm trying to do.

    The control is for the Detail property.

    Basically, what it "should" do is that when a record is Null then highlight that line or detail in the report.

    Here's a question...Instead of trying to change the property of the detail section would it be easier to create a box that is moved to the back and then just toggle the control color on the box? I think that may be easier.

    Any thoughts?

    Cause this detail thing is for the birds...

    -C

  8. #8
    Join Date
    Dec 2002
    Posts
    97

    Idiot

    Okay M.timoney....I'm an idiot...I'll admit it.

    Before fully looking at your code I responded say that the text box wasn't it.

    Yes...that will work. My apologies.

    Thank you for the assistance.

    Sigh....

    And sometimes it's the EASY ones that get you!

    Thanks again.
    -C

  9. #9
    Join Date
    Jul 2002
    Location
    Romania
    Posts
    122
    Section(acDetail).BackColor = IIf(IsNull(MyField), clrLtGrey, clrWhite)



    The flaw in your code:

    If rpt![myField] Is Null Then

    should be

    If IsNull(rpt![myField]) Then

    More thoughts:
    You're inspecting a textbox from code launched within the report. You can get rid of the object variable and refer to the report as Me. Or nothing - like in my example.
    The brackets are only needed when the object name contains spaces. Yours doesn't.

  10. #10
    Join Date
    Dec 2002
    Posts
    97

    Object Variables and Brackets

    Danny,

    Thank you for the code it worked fine.

    Here's a question. I've used Me! in other languages and have been warned away from it's use. The better option was to explicitly state the Object. Thoughts?

    Also, the brackets, call it force of habit. I use them mainly so I don't forget them.

    Thanks again for the help.

    -C

  11. #11
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820

    Re: Object Variables and Brackets

    Originally posted by Mr_Yabbo
    Danny,

    Thank you for the code it worked fine.

    Here's a question. I've used Me! in other languages and have been warned away from it's use. The better option was to explicitly state the Object. Thoughts?

    Also, the brackets, call it force of habit. I use them mainly so I don't forget them.

    Thanks again for the help.

    -C
    it really makes no difference object! means something on/in the object where as object. means something thats part of the object
    i personaly use object. and object(""). and very rarely object!
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  12. #12
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    hold on after reading again what you said are you asking about . ! notaion or implict declaration?

    ie the first Me. over me!

    or me. over form_main.

    if it the second it makes absolutly no difference what so ever as long as you don't use it when me isn't the object you think it is
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

Posting Permissions

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