Changing properties on a continuous form (1 Viewer)

mcomp72

Member
Local time
Today, 03:15
Joined
Jul 7, 2023
Messages
38
I have a continuous form, and there's a button on it that runs some VBA code. The code takes information that's in the detail area of the form and writes it to a table.

There will be some records on the form that will be ignored -- every record will not have data that gets written to the aforementioned table. For the records that do, I would like to have the background color of one of the fields in the detail area of the form changed to blue.

The way I have thinking about it is, after the code runs that writes the data to the table, I could then do the following:

Loop through each record on the continuous form and do this:
If the ScoreRecorded field = True then make the background color of the Points field blue.

ScoreRecorded is a field of type YES/NO.

I have tried to figure out how to do this, but I can't seem to get it. I found a post on StackOverflow that talks about using Me.Detail.Controls, but I can't figure out how to make sense of it.

Any ideas on the best way to do this?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 11:15
Joined
Feb 19, 2013
Messages
16,619
Have you tried using conditional formatting?
 

mcomp72

Member
Local time
Today, 03:15
Joined
Jul 7, 2023
Messages
38
Nope. Had never even heard of it. I knew Excel could do that, but not Access. I'll google it and read up on it. Thanks!
 

CJ_London

Super Moderator
Staff member
Local time
Today, 11:15
Joined
Feb 19, 2013
Messages
16,619
It works much the same way although some controls such as subforms and checkboxes cannot be conditionally formatted
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:15
Joined
Feb 19, 2002
Messages
43,302
@mcomp72 welcome to AWF. You seem to have your Excel hat on so we'll help you to things the relational database way.
1. It is rarely right to move records from one table to another and it is even more rare to have to copy them so they end up in both places which is what you are doing. Relational databases work using set theory. Queries operate on sets of data. The query you are using to copy the records is able to select the set of data you want to work with so there is no reason to duplicate the data. Just use the logic that selects the set whenever you want to work with just that set of data. Now, there are situations where moving and even copying are rational, but the situations are quite rare.
2. "Loop through each record on the continuous form and do this:
If the ScoreRecorded field = True then make the background color of the Points field blue." In a table, individual "cells" which are actually the intersection of a row and column and NOT "cells" at all, are not addressable as they are with Excel. In a relational database, we work with queries that select a set of rows using a WHERE clause. Then the individual columns are addressed by name. Therefore, there is no way to assign attributes like color to any "cell" because "cells" do not exist as a concept. In order to use conditional formatting, you would need to use the selection criteria used in your append query.

If you need help with your schema, it is easiest if you post a database. If you want ideas on how to accomplish your task without duplicating data, please start a new thread.
 

Users who are viewing this thread

Top Bottom