Control Affecting All Controls on SubForm

K

Kenny G

Access 2003

I've got a main form "frmMain" and a "subform "sfrmFindings" on record 444
of frmMain the subform "sfrmFindings" I have 12 records on the subform for
record 444. I have a control "FindCorrCompleted," this control is a primary
control on the subform (see code below). The problem I am having is that
when I am on record 12 and click the control FindCorrCompleted this action
affects all 12 entries under 444 not just the 12th.

Would someone tell me what exactly is happening here? Thanks in advance for
your assistance.


Private Sub FindCorrCompleted_AfterUpdate()
If Me.FindCorrCompleted = True And Me.Standard <> " " Then
Me.Standard.Enabled = False
Me.NCM = "Y"
Else
If Me.FindCorrCompleted = False And Me.Standard = "" Then
Me.Standard.Enabled = True
Me.NCM = "N"
Else
If Me.FindCorrCompleted = False And Me.Standard <> "" Then
Me.Standard.Enabled = True
Me.NCM = "N"
End If
End If
End If
If Me.FindCorrCompleted = True And Me.Standard2 <> " " Then
Me.Standard2.Enabled = False
Me.NCM2 = "Y"
Else
If Me.FindCorrCompleted = False And Me.Standard2 = "" Then
Me.Standard2.Enabled = True
Me.NCM2 = "N"
Else
If Me.FindCorrCompleted = False And Me.Standard2 <> "" Then
Me.Standard2.Enabled = True
Me.NCM2 = "N"
End If
End If
End If
If Me.FindCorrCompleted = True And Me.Standard3 <> " " Then
Me.Standard3.Enabled = False
Me.NCM3 = "Y"
Else
If Me.FindCorrCompleted = False And Me.Standard3 = "" Then
Me.Standard3.Enabled = True
Me.NCM3 = "N"
Else
If Me.FindCorrCompleted = False And Me.Standard3 <> "" Then
Me.Standard3.Enabled = True
Me.NCM3 = "N"
End If
End If
End If
If Me.FindCorrCompleted = True And Me.Standard4 <> " " Then
Me.Standard4.Enabled = False
Me.NCM4 = "Y"
Else
If Me.FindCorrCompleted = False And Me.Standard4 = "" Then
Me.Standard4.Enabled = True
Me.NCM4 = "N"
Else
If Me.FindCorrCompleted = False And Me.Standard4 <> "" Then
Me.Standard4.Enabled = True
Me.NCM4 = "N"
End If
End If
End If
If Me.FindCorrCompleted = True And Me.Standard5 <> " " Then
Me.Standard5.Enabled = False
Me.NCM5 = "Y"
Else
If Me.FindCorrCompleted = False And Me.Standard5 = "" Then
Me.Standard5.Enabled = True
Me.NCM5 = "N"
Else
If Me.FindCorrCompleted = False And Me.Standard5 <> "" Then
Me.Standard5.Enabled = True
Me.NCM5 = "N"
End If
End If
End If
End Sub
 
K

Klatuu

Datasheet and Continuous forms can be misleading until you understand a basic
concept about them. Although you see what appears to be multiple controls,
it is, in fact, just multiple instances of the same control. So, anything
you do that address the properties of a control affects them all. That is,
with the exception of the value of the control. When you retrieve or modify
the value of a control, it only affects the value of the current row.
 
K

Kenny G

Klatuu,


The subform(s) are neither datasheet nor continuous. The subform is a
"singleform".
If I click the checkbox for FindCorrCompleted for the first record on the
subform that action has the same effect on all of the twelve.
 
K

Klatuu

My mistake. I took "I have 12 records on the subform" to mean it was one of
the other types.

In this case, you are setting control properties, but you are not changing
them for each record, You are changing them in the After Update event of the
control FindCorrCompleted. They will not automatically reset when you change
records. If that is what you want, then you will need to use the subform's
Current event and set the control properties for each record.
 
K

Kenny G

Klatuu,

That did it - many thanks!
--
Kenny G


Klatuu said:
My mistake. I took "I have 12 records on the subform" to mean it was one of
the other types.

In this case, you are setting control properties, but you are not changing
them for each record, You are changing them in the After Update event of the
control FindCorrCompleted. They will not automatically reset when you change
records. If that is what you want, then you will need to use the subform's
Current event and set the control properties for each record.
 

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