Share via

Access 2016 conditional formatting using vba

Anonymous
2018-05-12T10:21:00+00:00

Hi Access Forum Group, 

Does anyone know the Syntax of vba for the formatting of colours of cells within the table area

of a query within a form.

I have a function module with loop on a recordset that examines each row/column intersection.

Dim rs As DAO.recordset

Set rs = Forms("name").recordset

fieldcounter = rs.Fields.Count

for i = 1 to fieldcounter

rs.Fields(i).value

Next i

I am unsure how to now set this intersection to be colour coded?

Pseudo code would be 

rs.Fields(i).backcolor = vbGreen

If anyone would be able to assist.

Thank you.

Simon

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2018-05-12T11:03:56+00:00

Just to clear up some terminology, so everyone is on the same page in Access we don't really have rows, columns, intersections...

Row -> Record

Column -> Field

It would go a long way if you gave us a concrete example or 2 to develop code for because there are a multitude of way to do this.   Might I also ask why you don't just use the Conditional Formatting wizard in the form directly?

Have you seen https://blogs.msdn.microsoft.com/frice/2004/06/08/adding-additional-conditional-formatting-in-access-with-vba/ ?

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2018-05-13T00:57:57+00:00

    Thank you ver much Daniel

    i have not encountered this page yet.

    but as an update

    i thought about what you first  said

    i added the additional field value in the string

    and then in the conditional formatting

    i uswd tge instr functiion

    it all works now thank you

    Simon

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2018-05-12T11:20:39+00:00

    Thank you kindly Daniel

    you are correct indicating records and fields.

    yes also the field values are the reason why i am using  a function module. They are concatenated strings.

    i have to split them up to get the primary key.

    situation is when the field contains string of resolved 

    then green. If active in the string then yelliw 

    i will later write some detailed code i did. 

    for now i just need the last line of vba that 

    says 

    selected field location - change colour of field background. 

    Thank you again

    Simon

    Was this answer helpful?

    0 comments No comments