How to use a compund Primary Key?

Schlingel

Registered User.
Local time
Today, 04:57
Joined
Oct 26, 2006
Messages
32
Hi
I have a little problem. I have a database with two tables: Nachweis and Entschuldigungen. In the first one u can add the records of what u have done for every day, the second one is for the days when u were absent.
I need to let the user to add in the second table only records which are NOT included in the first one. So if i have records for 10.10.2006 in the first table, i can't add records for 10.10.2006 in the second one. I wanna do it with help of the Compound Primary Key. But i don't even know where i should start.
Any help will be appreciated
Thanks in advance
 
Hi

When you will add records in the second table you will need to use Dlookup function to verify if there exist in the first table.Example: Dlookup("[newdata]","[table1]","[newdata='" & Me.txt.....&"'")
See how Dlookup works!!
And if your compound key contains lets say 2 elements you can use Dlookup to verify that like this: Dlookup("[newdata]","[table1]","[newdata='" & element 1 &"' & "AND" & '" & element 2 &"'")
 
Last edited:
Thanks for ur reply, but Access writes me a syntax error in Criteria
items = DLookup("[Datum]", "Entschuldigung", "[Datum]= 10.10.2006")
 
Last edited:
Try this:
items = DLookup("[Datum]", "Entschuldigung", "[Datum]=#" & Month(10.10.2006) & "/" & Day(10.10.2006) & "/" & Year(10.10.2006) & "#"

in dlookup you have: for text '"....."', for number only "...." and for date with ##
 
The real problem is that you are using two tables when you should be using one.
 

Users who are viewing this thread

Back
Top Bottom