R
Roger Bell
I have a field in a Data Form called "Section Name" and this is a Text Field
where the user enters for example 1A, 1B etc.
I would like an After Update event Procedure which prevents the user from
entering duplicates with an appropriate error message. I have been able to
do this with a number field but not with a text field.
This is the code I used for a number field:
Private Sub Envelope_Number_AfterUpdate()
If IsNull(Me.Envelope_Number) = True Then
'Do nothing NUll is acceptable
DoCmd.RunCommand acCmdSaveRecord
[Combo561].Requery
ElseIf DCount("*", "[Main Table]", "[Envelope Number]=" &
Me.Envelope_Number) > 0 Then
MsgBox "SORRY, THIS NUMBER IS ALREADY IN USE. IF YOU WISH TO ALLOCATE THIS
NUMBER, YOU MUST REMOVE THE NUMBER FROM THE MEMBER TO WHOM IT IS CURRENTLY
ALLOCATED. PLEASE NOTE THAT YOU MUST NOT RE-ALLOCATE ENVELOPE NUMBERS DURING
THE PLANNED GIVING CYCLE AS THIS WILL AFFECT THE FINANCIAL REPORTING",
vbOKOnly, "ERROR! MESSAGE"
Cancel = True
Me.[Envelope Number] = Null
DoCmd.RunCommand acCmdSaveRecord
End If
End Sub
Can the above code be modified for a text field?
Thanks for any help
where the user enters for example 1A, 1B etc.
I would like an After Update event Procedure which prevents the user from
entering duplicates with an appropriate error message. I have been able to
do this with a number field but not with a text field.
This is the code I used for a number field:
Private Sub Envelope_Number_AfterUpdate()
If IsNull(Me.Envelope_Number) = True Then
'Do nothing NUll is acceptable
DoCmd.RunCommand acCmdSaveRecord
[Combo561].Requery
ElseIf DCount("*", "[Main Table]", "[Envelope Number]=" &
Me.Envelope_Number) > 0 Then
MsgBox "SORRY, THIS NUMBER IS ALREADY IN USE. IF YOU WISH TO ALLOCATE THIS
NUMBER, YOU MUST REMOVE THE NUMBER FROM THE MEMBER TO WHOM IT IS CURRENTLY
ALLOCATED. PLEASE NOTE THAT YOU MUST NOT RE-ALLOCATE ENVELOPE NUMBERS DURING
THE PLANNED GIVING CYCLE AS THIS WILL AFFECT THE FINANCIAL REPORTING",
vbOKOnly, "ERROR! MESSAGE"
Cancel = True
Me.[Envelope Number] = Null
DoCmd.RunCommand acCmdSaveRecord
End If
End Sub
Can the above code be modified for a text field?
Thanks for any help