subform in datasheet view - enable fields on current row/record on

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have code in the afterupdate event to enable certain fields when a
condition is met. How do I limit the rule to apply the current record/row
only as it seems to apply to all other records on the datasheet.

If the current row has a withdraw date it will enable the withdraw reason
field for all other rows as well as the current row.

The code is

If Me.dtWithdrawdate <> "" Then
Me.txtWithdrawreason.Enabled = True
Me.txtWithdrawreason.SetFocus
Else
Me.txtWithdrawreason = Null
Me.txtWithdrawreason.Enabled = False

End If
 
Kellie,

Put contol disable/enable code in the OnCurrent event - provided it is not a
continous form. Do not do the SetFocus in the OnCurrent. Put additional
disable/enable code in the AfterUpdate of the field.

MikeC
 
Thanks for your reply Mike
I'm not sure what code to put in the Current event and what code to put in
the afterupdate event of the field
 
Kellie,

Something like this for OnCurrent:

If Not IsNull(Me.dtWithdrawdate) Or Me.dtWithdrawdate <> "" Then
Me.txtWithdrawreason.Enabled = True
Else
Me.txtWithdrawreason.Enabled = False
End If

will enable or disable the txtWithdrawreason control based on dtWithdrawdate
having not having a null or a blank.

Put the exact same code into the AfterUpdate event on the dtWithdrawdate
control - plus the set to null and setfocus if you like.

MikeC
 
Back
Top