How to loop through records on a form locking the form

A

Al

I have a subform that displays in datasheet form records related to the
parent record. I would like to loop through the subform records setting the
lock and background attributes based upon the value of a variable in the
form.current event. I can do this for one record, but how can it be dome for
all the records? Or what am I missing here?

This code does it for only 1 record:

Private Sub Form_Current()

Dim ctl As Control

For Each ctl In Me.Controls
If Me.Void then
ctl.Locked = True
If ctl.ControlType = acTextBox Then ctl.BackColor =
gclng_Yellow
If ctl.ControlType = acComboBox Then ctl.BackColor =
gclng_Yellow
Else
ctl.Locked = False
If ctl.ControlType = acTextBox Then ctl.BackColor =
vbWhite
If ctl.ControlType = acComboBox Then ctl.BackColor =
vbWhite
End If
Next
Exit_Here:
Exit Sub

End Sub

Thanks for your replies!!
 
J

John Spencer

Actually that code does it. There is only one set of controls for a form.
You SEE multiple copies of the controls in continous form view, but they are
all the same control.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top