By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,833 Members | 2,067 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,833 IT Pros & Developers. It's quick & easy.

Field Formatting Problem in SubForm

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a

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 discussion thread is closed

Replies have been disabled for this discussion.