[AccessD] Hope for the Best, Anticipate the Worst

Gustav Brock gustav at cactus.dk
Sat Jan 22 07:39:41 CST 2022


Hi Kostas

Reduce it a little:

If DCount("*", "st_kritiki", "code_kritiki = '" & Me!code_kritiki.Value & "'") > 0 Then
    Cancel = True
End If

/gustav

Fra: Kostas Konstantinidis<mailto:kost36 at gmail.com>
Sendt: 22. januar 2022 14:16
Til: 'Access Developers discussion and problem solving'<mailto:accessd at databaseadvisors.com>
Emne: Re: [AccessD] Hope for the Best, Anticipate the Worst

Hi guys,
I am trying to prevent duplicate data in a numeric field and I use:

Private Sub code_kritiki_BeforeUpdate(Cancel As Integer)
'On Error Resume Next
    If DCount("*", "st_kritiki", "code_kritiki='" & Me.code_kritiki.Value &
"' and code_kritiki='" & Me.code_kritiki.Value & "'") > 0 Then
        MsgBox "Some Greek text", vbInformation, "some Greek text"
        Me.code_kritiki.SetFocus
        Cancel = True
 End If
End Sub

The problem is that it breaks on any value I am trying to enter
Thank's
/kostas



More information about the AccessD mailing list