Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2011
    Posts
    11

    Unanswered: Applying code to only 1 record not all...

    Hi, Newbie here.

    I am trying to use code to make a row/record turn bold when a check box is checked. The code goes something like this:
    Private Sub Resolved_Click()

    If Resolved.Value = True Then
    Date_Drawn.FontBold = True

    Else
    Date_Drawn.FontBold = False

    End If

    If Resolved.Value = True Then
    Slip_No.FontBold = True

    Else
    Slip_No.FontBold = False

    End If

    If Resolved.Value = True Then
    Last_Name.FontBold = True

    Else
    Last_Name.FontBold = False

    End If

    ...(for several more)

    It works wonderfully. The problem now, is that when the first checkbox is checked, the bold applies to all of the records in the form instead of just the one it was intended for. I would like to find a way to have the code apply only to the record that includes that particular checkbox.

    Thanks!

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    1. If Resolved is the name of the CheckBox, you could simply write:
    Code:
    Private Sub Resolved_AfterUpdate()
    
        Date_Drawn.FontBold = Resolved.Value
        Slip_No.FontBold = Resolved.Value
        Last_Name.FontBold = Resolved.Value
        Last_Name.FontBold = Resolved.Value
        ' code continues...
    End Sub
    2. Is the form in Datasheet or Continuous view (which I suspect)?
    Have a nice day!

  3. #3
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    I would use Conditional Formatting rather than code. Code will work okay in a report, but not in a continuous or datasheet form.
    Paul

  4. #4
    Join Date
    Dec 2011
    Posts
    11
    I am doing this in a continuous form.

  5. #5
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Did you see this post?

    Quote Originally Posted by pbaldy View Post
    I would use Conditional Formatting rather than code. Code will work okay in a report, but not in a continuous or datasheet form.
    Paul

  6. #6
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Conditional Formatting is indeed the solution for a continuous form or a form in Datasheet view.
    Have a nice day!

  7. #7
    Join Date
    Dec 2011
    Posts
    11
    Thank you very much!

  8. #8
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    FYI, you can set CF to all of the Controls at once, in Form Design View, by

    1. Holding down <Shift> and Left clicking on each Control in turn.
    2. On the Menu go to FormatConditional Formatting
    3. Under Condition1 use the Down Arrow to select Expression Is
    4. In the next box type in [Resolved] = -1
    5. Click on the Bold icon.
    6. Click OK


    You're done!

    Linq ;0)>
    Last edited by Missinglinq; 12-11-11 at 12:14.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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