Using AfterUpdate on checkbox to enable/disable a field.

A

August

I'm using the AfterUpdate function to enable/disable a
field on a continuous form. The code looks like this:

Private Sub LetterSent_AfterUpdate()
If Me.LetterSent.Value = 0 Then
Me.LetterSentDate.Enabled = False
Me.LetterSentDate.Value = Null
Else
Me.LetterSentDate.Enabled = True
Me.LetterSentDate.Value = Date
End If
End Sub

Here is the problem: When the box is checked it correctly
inputs the date in the record that is checked. However,
it enables or disables every LetterSentDate field on the
form, not just the current record.

Help!

Thanks in advance.
 
R

Rick Brandt

August said:
I'm using the AfterUpdate function to enable/disable a
field on a continuous form. The code looks like this:

Private Sub LetterSent_AfterUpdate()
If Me.LetterSent.Value = 0 Then
Me.LetterSentDate.Enabled = False
Me.LetterSentDate.Value = Null
Else
Me.LetterSentDate.Enabled = True
Me.LetterSentDate.Value = Date
End If
End Sub

Here is the problem: When the box is checked it correctly
inputs the date in the record that is checked. However,
it enables or disables every LetterSentDate field on the
form, not just the current record.

If you added a label to a continuous form would you expect to see it on
only one row in the form or on all rows? The same thing applies here.
There is only ONE LetterSentDate control that is being copied for display
on all of the rows in your continuous form. You cannot change the
properties of a control such that it will only affect some of the rows
being displayed since they all use the same controls.

If you duplicate your code in the Current event of the form then the
LetterSentDate will change to the appropriate state as you move from row to
row. Visually though it will still affect all rows.
 

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