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

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
 
G

Guest

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
 
G

Guest

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
 
G

Guest

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
 

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