P
PeteCresswell
Got a field on a multi-row subform that should only be allowed tb
changed if certain conditions are met.
I don't know any way of making it editable/non-editable on-the-fly, so
I'm doing this - which seems kind of kludgey to me, although I guess I
could mitigate things slightly by using Conditional Formatting to vary
the backcolor of the field so the user sees whether it is going tb
allowed an edit or not...
Is there a better way?
====================================================
Private Sub txtRate_BeforeUpdate(Cancel As Integer)
DebugStackPush Me.Name & ": txtRate_BeforeUpdate"
On Error GoTo txtRate_BeforeUpdate_err
' PURPOSE: To to allow editing only buy items where Settlement=Issue
date
With Me
If Not ((.txtTradeTypeID = gTradeTypeID_Buy) And (DateDiff
("d", .txtSettlementDate, .Parent!subSecurity.Form!txtIssueDate) = 0))
Then
Cancel = True
MsgBox "You may only change Buy Rate on buys and where
settlement and issue date are equal." & vbCrLf & vbCrLf & "Press the
Esc key to restore old value and exit the field.", vbExclamation,
"Change Not Allowed"
End If
End With
txtRate_BeforeUpdate_xit:
DebugStackPop
On Error Resume Next
Exit Sub
txtRate_BeforeUpdate_err:
BugAlert True, ""
Resume txtRate_BeforeUpdate_xit
End Sub
====================================================
changed if certain conditions are met.
I don't know any way of making it editable/non-editable on-the-fly, so
I'm doing this - which seems kind of kludgey to me, although I guess I
could mitigate things slightly by using Conditional Formatting to vary
the backcolor of the field so the user sees whether it is going tb
allowed an edit or not...
Is there a better way?
====================================================
Private Sub txtRate_BeforeUpdate(Cancel As Integer)
DebugStackPush Me.Name & ": txtRate_BeforeUpdate"
On Error GoTo txtRate_BeforeUpdate_err
' PURPOSE: To to allow editing only buy items where Settlement=Issue
date
With Me
If Not ((.txtTradeTypeID = gTradeTypeID_Buy) And (DateDiff
("d", .txtSettlementDate, .Parent!subSecurity.Form!txtIssueDate) = 0))
Then
Cancel = True
MsgBox "You may only change Buy Rate on buys and where
settlement and issue date are equal." & vbCrLf & vbCrLf & "Press the
Esc key to restore old value and exit the field.", vbExclamation,
"Change Not Allowed"
End If
End With
txtRate_BeforeUpdate_xit:
DebugStackPop
On Error Resume Next
Exit Sub
txtRate_BeforeUpdate_err:
BugAlert True, ""
Resume txtRate_BeforeUpdate_xit
End Sub
====================================================