Results 1 to 4 of 4
  1. #1
    Join Date
    May 2003
    Location
    UK
    Posts
    233

    Unanswered: Conditional Formatting using Vb Code

    I want to apply conditional formatting using code to a textbox on a continuous form. The condition depends
    on the record that is selected. A command button sits next to each record on the form.

    I can identify the record that has been selected by a variable using

    sMyID = Forms!frmCost_Reconciliation!txtID

    I then want to change the colour of the record that has been selectd and only that record.
    This is the part I an having a problem with.

    I want someting like:
    If txtID - sMyID Then
    txtID.Backcolor = vbBlue
    End If

    Or something like this but this does not work.

  2. #2
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231
    If txtID - sMyID Then
    Should this be =, vs -?

    Are you using continuous forms? What is the condition suposed to be under which you're turning the text blue?

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    AFAIK you cannot apply conditional formatting to a specific row, the test is based on the current row, and the changes applied to all rows shown in the continuous form.

    if you could not change (say) the colour of one text box, all representations of that text box on the form will be changed.

    you'll have to think of another way round this problem.. a possibility is to use the continuous form to carry the briefest details of the row, and a sub form tied to the selected row to display the detail. do any conditional formatting on the subform
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    May 2003
    Location
    UK
    Posts
    233
    Yes it should be txtID = sMyID.

    I have a solution but a bit messy. I could update a field(format) in the table based on if txtID = sMyID. Requery the form and set the condtional formating in the control if that field(Format = "Yes") then format accordingly.

    This is I guess will work just seems messy and painful.

Posting Permissions

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