Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apply VBA code to individual records

Status
Not open for further replies.

edwilli

Programmer
May 22, 2003
33
US
I have a form with multiple records on it. These records fall into two categories: approved, or not approved. Records that are approved I would like to highlight in green. However the following code only looks at the first record and applies the results to ALL the records:

Private Sub Form_Load()
If intStatus = 2 Then
Me.RecordTitle.ForeColor = RGB(0, 255, 0)
End If
End Sub

How can I have this logic applied to each individual record?

Many thanks in advance!

Eric
 
I've never got it to work with subforms and I have never tried too hard. In Access 2000 or better (I don't know about earlier versions), there is Conditional Formatting under the Format menu. This might help.
 
This isn't a sub form. The code is a subroutine I run when the form is loaded. Unfortunately the code cannot distinguish the between the multiple records on the form.
 
Ooh! I thought you meant multiple records "at the same time". Do you mean that you can navigate through a recordset on the form one record at a time?

If so, put the code in the Form_Current event rather than Form_Load.

If not, then I don't understand how you are displaying more than one record on the form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top