472,784 Members | 861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,784 software developers and data experts.

Field Formatting Problem in SubForm

Hello,
In an Access 2003 ADP Subform, I am trying to set the BackGround color
of three textbox fields (LSScore, RScore, WScore) in the current
record of the subform to zero (black) if the value of a bound checkbox
field (Spanish) on the current record is True, and to 16777164 if the
value of the bound checkbox field is False.

The Subform's Name property is 'frmMainScores'. The Source Object
Property of the Subform is 'frmMainSubScores'. The Default View
property of the form 'frmMainSubScores' is set to Continuous Forms.

The following is the code that I have for the Form_Current of the
subform:
**************************************************
Private Sub Form_Current()

If (Forms!frmMain!frmMainScores.Form!Spanish = True) Then
Forms!frmMain!frmMainScores.Form!LSScore.BackColor = 0
Forms!frmMain!frmMainScores.Form!RScore.BackColor = 0
Forms!frmMain!frmMainScores.Form!WScore.BackColor = 0

ElseIf (Forms!frmMain!frmMainScores.Form!Spanish = False) Then
Forms!frmMain!frmMainScores.Form!LSScore.BackColor = 16777164
Forms!frmMain!frmMainScores.Form!RScore.BackColor = 16777164
Forms!frmMain!frmMainScores.Form!WScore.BackColor = 16777164
End If

End Sub
*************************************************

I am not getting the results that I expected with this code. If
'Spanish' in the first record of the subform = True, then the three
fields for every record have a background color of zero, regardless of
whether or not 'Spanish' = True.

The background color of these three fields changes the way I expect
the change to occur only if I click the subform record selector for
each record, but the the background color change occurs for every
record by the condition of 'Spanish' for the record that I click on.
In other words, If I click on the subform record selector of a record
where 'Spanish' is True, then the background color of the three fields
turns black for every record in the subform. If I click on the subform
record selector of a record where 'Spanish' is False, then the
background color of the three fields becomes 16777164 for every record
in the subform.

A single main form record can have multiple subform records, and those
subform records can have any number of records where 'Spanish' is True
or False.

How can I set up my code so that the three fields in the subform have
the correct background color for each condition of 'Spanish' in each
record?

Thanks for your help!

CSDunn
Nov 12 '05 #1
2 2780
In design mode, try Right Clicking the control and choosing Conditional
Formatting. Set the condition to Expression Is and type in the expression to
the checkbox (you may be able to get by with just typing in Spanish). Set
the back color to your desired choice. The color will be set when the
expression (Spanish) is true. Set the other color to be the default color
and it will show when Spanish is false.

--
Wayne Morgan
Microsoft Access MVP
"CSDunn" <cd***@valverde.edu> wrote in message
news:80*************************@posting.google.co m...
Hello,
In an Access 2003 ADP Subform, I am trying to set the BackGround color
of three textbox fields (LSScore, RScore, WScore) in the current
record of the subform to zero (black) if the value of a bound checkbox
field (Spanish) on the current record is True, and to 16777164 if the
value of the bound checkbox field is False.

The Subform's Name property is 'frmMainScores'. The Source Object
Property of the Subform is 'frmMainSubScores'. The Default View
property of the form 'frmMainSubScores' is set to Continuous Forms.

The following is the code that I have for the Form_Current of the
subform:
**************************************************
Private Sub Form_Current()

If (Forms!frmMain!frmMainScores.Form!Spanish = True) Then
Forms!frmMain!frmMainScores.Form!LSScore.BackColor = 0
Forms!frmMain!frmMainScores.Form!RScore.BackColor = 0
Forms!frmMain!frmMainScores.Form!WScore.BackColor = 0

ElseIf (Forms!frmMain!frmMainScores.Form!Spanish = False) Then
Forms!frmMain!frmMainScores.Form!LSScore.BackColor = 16777164
Forms!frmMain!frmMainScores.Form!RScore.BackColor = 16777164
Forms!frmMain!frmMainScores.Form!WScore.BackColor = 16777164
End If

End Sub
*************************************************

I am not getting the results that I expected with this code. If
'Spanish' in the first record of the subform = True, then the three
fields for every record have a background color of zero, regardless of
whether or not 'Spanish' = True.

The background color of these three fields changes the way I expect
the change to occur only if I click the subform record selector for
each record, but the the background color change occurs for every
record by the condition of 'Spanish' for the record that I click on.
In other words, If I click on the subform record selector of a record
where 'Spanish' is True, then the background color of the three fields
turns black for every record in the subform. If I click on the subform
record selector of a record where 'Spanish' is False, then the
background color of the three fields becomes 16777164 for every record
in the subform.

A single main form record can have multiple subform records, and those
subform records can have any number of records where 'Spanish' is True
or False.

How can I set up my code so that the three fields in the subform have
the correct background color for each condition of 'Spanish' in each
record?

Thanks for your help!

CSDunn

Nov 12 '05 #2

Thanks, I will try this.

CSDunn
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
8
by: Dimitri Furman | last post by:
Given: Access 2002/2003 A subform in datasheet or continuous view, placed on a tab page (this last may or may not matter) Conditional formatting applied to some controls on the subform - format...
4
by: midlothian | last post by:
Hello, I have conditional formatting set up on a subform based on a calculated value in the underlying query. For instance, if Sales are >$1000, the query displays "Yes," otherwise it displays...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
4
by: Don Do | last post by:
Help I built a form/subform/subsubform setup using the access forms wizard. I have a table1 = parent, table2 = child, table3 = (grandchild?). There will be multiple records in table2 that tie...
6
by: ApexData | last post by:
I have created a Search Form that is basically a Popup ContinuousForm that consists of 15 fields(columns). When the user clicks on a record(row) the form closes and the selected record displays on...
7
by: Katherine | last post by:
I'm trying to filter the records on the mainform (MailingList) of my database using a field contained in a subform (Donations). I was basing my code off Allen Browne's Access Tips page (here:...
4
by: TD | last post by:
I am trying to change the forecolor of a field in a subform that is in datasheet view. I am using Access 2007. I have tried everything I can think of to do this but the text still appears in...
2
by: DeanL | last post by:
Hi guys, I'm using a subform to display a list of values from a single table. The form is showing the values in "continuous forms" view and there will only ever be two different values for the...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.