no duplicate records

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

Guest

Hello
I’m from Portugal and sometimes I verify your Discussion Group. I found one
verify usefully for my BD, but when I try, the code that I found, the result
was not very good, I ask you, if you can help me????
Here is the code:
Private Sub turno_BeforeUpdate(Cancel As Integer)

On Error GoTo err_exit_this_sub

Dim x1, x2 As Variant

x1 = DLookup("[data]", "[dados_desperdicio]", "[data]=#" &
Format(Forms![formulario_desperdicio]![data], "dd-mm-yyyy") & "#")
x2 = DLookup("[turno]", "[dados_desperdicio]",
"[turno]=Forms![formulario_desperdicio]![turno]")

If utilizadorbasededados = "Alda Gama" Or utilizadorbasededados = "I&D" Or
utilizadorbasededados = "Logistica" Or utilizadorbasededados = "Fornecedores"
Or utilizadorbasededados = "Teresa Forte" Or utilizadorbasededados = "Rui
Barrau" Or utilizadorbasededados = "Filipe Pinto" Or utilizadorbasededados =
"Nuno Pereira" Or utilizadorbasededados = "Marisa Gonçalves" Or
utilizadorbasededados = "Paulo Aguas" Or utilizadorbasededados = "Joaquim
Afonso" Or utilizadorbasededados = "Amelia Paulino" Or utilizadorbasededados
= "Carlos Vinhas" Then
If Not IsNull(x1) And Not IsNull(x2) Then
Beep
MsgBox "Já Existe um Registro para esta Data e Equipa", vbOKOnly,
"Atenção à Duplicação de Registros"
Cancel = True
End If
End If

exit_this_sub:
Exit Sub

err_exit_this_sub:
MsgBox Error$
Resume exit_this_sub
End Sub

PS – I need one message of error when the same person wrote the same Date
and the same shipment
 
hi,

Does this code generates an error or incorrect results.

PLease send the database schema so that we can verify the code against the
database.

Regards,
 
Hello:
This code doesn’t give me an error, the situation is, I made the login with
one of the persons who are in the cycle of IF, for example:
I made the login with Alda, I put the date and the shipment (A, B, C) all
different, and I fulfill the rest of formulary. When I pass for another
login, which is different from Alda, the code says please the record already
exists, but the login is different.
My table has this champs: user, data, chip, machine, values….

Can you help me?

Designing-Systems.com said:
hi,

Does this code generates an error or incorrect results.

PLease send the database schema so that we can verify the code against the
database.

Regards,
-------------------------------------
http://www.Designing-Systems.com
Email. (e-mail address removed)
-----------------------------------------------

Luisa said:
Hello
I’m from Portugal and sometimes I verify your Discussion Group. I found one
verify usefully for my BD, but when I try, the code that I found, the result
was not very good, I ask you, if you can help me????
Here is the code:
Private Sub turno_BeforeUpdate(Cancel As Integer)

On Error GoTo err_exit_this_sub

Dim x1, x2 As Variant

x1 = DLookup("[data]", "[dados_desperdicio]", "[data]=#" &
Format(Forms![formulario_desperdicio]![data], "dd-mm-yyyy") & "#")
x2 = DLookup("[turno]", "[dados_desperdicio]",
"[turno]=Forms![formulario_desperdicio]![turno]")

If utilizadorbasededados = "Alda Gama" Or utilizadorbasededados = "I&D" Or
utilizadorbasededados = "Logistica" Or utilizadorbasededados = "Fornecedores"
Or utilizadorbasededados = "Teresa Forte" Or utilizadorbasededados = "Rui
Barrau" Or utilizadorbasededados = "Filipe Pinto" Or utilizadorbasededados =
"Nuno Pereira" Or utilizadorbasededados = "Marisa Gonçalves" Or
utilizadorbasededados = "Paulo Aguas" Or utilizadorbasededados = "Joaquim
Afonso" Or utilizadorbasededados = "Amelia Paulino" Or utilizadorbasededados
= "Carlos Vinhas" Then
If Not IsNull(x1) And Not IsNull(x2) Then
Beep
MsgBox "Já Existe um Registro para esta Data e Equipa", vbOKOnly,
"Atenção à Duplicação de Registros"
Cancel = True
End If
End If

exit_this_sub:
Exit Sub

err_exit_this_sub:
MsgBox Error$
Resume exit_this_sub
End Sub

PS – I need one message of error when the same person wrote the same Date
and the same shipment
 
Back
Top