check table for duplicates based on two fields

lipin

Registered User.
Local time
Today, 19:55
Joined
May 21, 2002
Messages
149
I am using dlookup to see if there is already a record with a date and name that is entered on a form.

If IsNull(DLookup("[Date]", "Roster", "[Date]= " & [Forms]![Roster1]![txtDate] & " AND [Supervisor]= " & [Forms]![Roster1]![txtSups])) Then....

I am looking in the "Roster" table to see if there is already a record that has the date and name that are on the form "Roster1". Supervisor is the name of the field in the table "Roster" that I want to check against also

but I keep getting the following error...

The expression you entered as a query parameter produced this error: 'The object doesn't contain the Automation object 'nameintextbox."

...where 'nameintextbox' is always the name I entered in the form textbox [txtSups]

why the error??
 
lipin,

Code:
If IsNull(DLookup("[Date]", _
                  "Roster", _
                  "[Date]= #" & [Forms]![Roster1]![txtDate] & "# AND " & _
                  "[Supervisor] = '" & [Forms]![Roster1]![txtSups] & "'")) Then....

BUT, Date is a RESERVED word and should not be used.

Wayne
 
Thank you very much. It works like a charm and I will change date to something else.
 
lipin,

Glad to hear it. You can look in Access Help for reserved words.
They can make things act strangely.

Wayne
 

Users who are viewing this thread

Back
Top Bottom