Record Validation

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

Guest

Hi,
I have this table with fields, date] and [employee] what I want it's to use
a form and when the user enter the combination of the date and employee that
allready had been used he gets a mesage of duplicated record. I know how to
do this using only one field (index) but I don't know how to do this using te
combination of two fields.

Ejem.

Date employee ID

07/20/05 154
07/20/05 141
07/20/05 154 (this combination it's the same on the top, so
its not valid)
 
Can you do simple VBA code? A little code to check if that record exists in
the table, or, depending on your form design, in the Form's RecordsetClone,
can easily do what you want.

One caution, however, "date" is an Access reserved word and should not be
used as a field name. It can be confusing when you think it should be
referring to the field and Access knows it is a built-in function that
returns today's date.

Larry Linson
Microsoft Access MVP
 
Hi Larry,
I don't realy know that mutch about VBA codes, I just star using access so
all this it's new for me, The real name for my fields are [Fecha] and [Num
empleado] that's spanish so please tell me if I need to change this names,
the table name it's "Detalle de datos" (detail data).
I have this Code on the before update event for the order number,(on the
same form) this one checks for duplicated records, but only on one field,
what do I need to change so this new code checks for the combination of
"fecha and Num empleado.

Private Sub orden_BeforeUpdate(Cancel As Integer)
If (Not IsNull(DLookup("[orden]", _
"DETALLE DE DATOS", "[ORDEN] ='" _
& Me!ORDEN & "'"))) Then
MsgBox "ESTA ORDEN YA FUE PROCESADA EN OTRA OCASION."
Cancel = True
Me!ORDEN.Undo
End If
End Sub


Thanks for all your time.

Larry Linson said:
Can you do simple VBA code? A little code to check if that record exists in
the table, or, depending on your form design, in the Form's RecordsetClone,
can easily do what you want.

One caution, however, "date" is an Access reserved word and should not be
used as a field name. It can be confusing when you think it should be
referring to the field and Access knows it is a built-in function that
returns today's date.

Larry Linson
Microsoft Access MVP


Sam 44 said:
Hi,
I have this table with fields, date] and [employee] what I want it's to
use
a form and when the user enter the combination of the date and employee
that
allready had been used he gets a mesage of duplicated record. I know how
to
do this using only one field (index) but I don't know how to do this using
te
combination of two fields.

Ejem.

Date employee ID

07/20/05 154
07/20/05 141
07/20/05 154 (this combination it's the same on the top, so
its not valid)
 
One method is to make the two fields yourkey field.
Open the table in design view. Highlight the two rows containing these
fields and click on the KEY icon on the tool bar.
 
Back
Top