alert me when entering duplicate names in an Access form

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

Guest

how can I set this up in an Access form? I do not want to prevent the data
from being entered, I just want to be notified. does anyone know of an
expression I could use for this?
 
Use the Before Update event of the text box you are entering the name in to
check your table:

If Not IsNull(DLookup("[SomeName]", "MyTableName", "[SomeName] = '" &
Me.txtName & "'")) Then
If MsgBox( Me.txtName & " Is Already In The table" & vbNewLine & "Ok to
use this name or Cancel", vbOkCancel + vbQuestion, "Duplicate Data") =
vbCancel Then
Cancel = True
End If
 
Thanks for the information. I cannot get the expression to work as I keep
getting an error that says "the expression you entered contains invalid
syntax". I entered it in the Before Update Event - Expressions area. Do you
know why it would give me that error message?

Thanks

Dawn

Klatuu said:
Use the Before Update event of the text box you are entering the name in to
check your table:

If Not IsNull(DLookup("[SomeName]", "MyTableName", "[SomeName] = '" &
Me.txtName & "'")) Then
If MsgBox( Me.txtName & " Is Already In The table" & vbNewLine & "Ok to
use this name or Cancel", vbOkCancel + vbQuestion, "Duplicate Data") =
vbCancel Then
Cancel = True
End If

Dawnie said:
how can I set this up in an Access form? I do not want to prevent the data
from being entered, I just want to be notified. does anyone know of an
expression I could use for this?
 
Post back with the code as you entered it and let me know which line it fails
on. You may be able to find the problem by compiling your application.

Dawnie said:
Thanks for the information. I cannot get the expression to work as I keep
getting an error that says "the expression you entered contains invalid
syntax". I entered it in the Before Update Event - Expressions area. Do you
know why it would give me that error message?

Thanks

Dawn

Klatuu said:
Use the Before Update event of the text box you are entering the name in to
check your table:

If Not IsNull(DLookup("[SomeName]", "MyTableName", "[SomeName] = '" &
Me.txtName & "'")) Then
If MsgBox( Me.txtName & " Is Already In The table" & vbNewLine & "Ok to
use this name or Cancel", vbOkCancel + vbQuestion, "Duplicate Data") =
vbCancel Then
Cancel = True
End If

Dawnie said:
how can I set this up in an Access form? I do not want to prevent the data
from being entered, I just want to be notified. does anyone know of an
expression I could use for this?
 
Back
Top