Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2004
    Posts
    364

    Angry Unanswered: HELP!! Checkbox needed to Grey out Text box in a report

    I need help quick!

    I have a check box on a form next to 4 fields of addresses (line one, line two, line 3, line 4). When the check box is checked I want the 4 fields of address on a report to turn light grey in their boxes.

    Ive done it so they turn grey on the form, but need it on the report aswell so it can be printed out.

    My form name is - sentence_history_new
    The checkbox in the form is called NFA
    The address box on the report (and form) is - address_1

    The code I entered is -

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If Forms("sentence_history_new").NFA.Value = True Then
    Address_1.BackColor = 12632256
    Else
    Address_1.BackColor = 16777215
    End If

    End Sub

    The above code was from a previous post, but it wont work. Any ideas why its not working?

  2. #2
    Join Date
    Sep 2004
    Posts
    161
    Put your form and your report in a base (97) and send it

  3. #3
    Join Date
    Aug 2004
    Posts
    364
    Heres a really basic database which has the table, form and report and the checkbox.
    Attached Files Attached Files

  4. #4
    Join Date
    Sep 2003
    Location
    MN US
    Posts
    313

    Hopefully I can save you guys some time...

    If you're using Acc2k or later you can use Conditional Formatting.

    Design View->Right click the text box(es)->Conditional Formatting

    Condition:

    Expression is [NFA] = -1

    (Would work in both the form and report and you don't need to code it)


    HTH.

    If you do need to code it, I think this is what your looking for:

    Code:
     
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
     
    	If Me!NFA.Value = -1 Then
    		 address_1.BackColor = 12632256
    	Else
    		 address_1.BackColor = 16777215
    	End If
     
    End Sub
    Last edited by cpgospi; 09-16-04 at 18:56. Reason: Adding correct code

  5. #5
    Join Date
    Aug 2004
    Posts
    364
    Just put that code in to the reports event procedure and nothing is happening, no errors, nothing. Ive got on record checked, and the other unchecked and the text box isnt changing color when checked :s

    Im using Office XP.

  6. #6
    Join Date
    Sep 2003
    Location
    MN US
    Posts
    313
    Hmmm,

    Here's what it looks like for me (address1 is coded, address4 is conditional formatting)

    Make sure it's in the OnFormat event of the Detail.
    Attached Thumbnails Attached Thumbnails report.jpg  

  7. #7
    Join Date
    Sep 2004
    Posts
    161
    I have search in the help
    EEK!for A2K (at home A2K at work A97) and i find this.
    For change the backcolor you must have the backStyle=Standard.
    It's work fine
    Last edited by jepi; 09-16-04 at 22:47.

  8. #8
    Join Date
    Aug 2004
    Posts
    364
    Got it to work I needed to set the reports text box back style property to normal (not transparent).

    Many thanks for your help, much appreciated!

Posting Permissions

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