Re: Prevent Duplicates



On Sat, 1 Aug 2009 10:55:01 -0700, TomC <TomC@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:

Hello, I am using a form which consists of a parent and one or many
children. The sub-forms are tied together with a Primary Key. The child
record contains an Auto Number, the Parent Primary Key, and a Date (short
format) among other elements. Anyway, my problem is how do I prevent the
keying of multiple children records with the same date? Thanks for any help
you may provide. hvc

Open the child table in design view and create a new Index. Put some
distinctive name (DupDates say) in the left column of the index toolbox, and
the ParentPrimaryKey field in the right. On the next line down leave the left
column blank and put the datefield (which should NOT be named Date, that's a
reserved word!!) in the right column. Check the "Unique" checkbox.

Now you won't be able to create duplicates on the combination of the fields.
--

John W. Vinson [MVP]
.



Relevant Pages

  • Re: MS Access
    ... primary key has some blank, ... We can call this our parent or so called "main" table. ... you must declare a new column in this child table. ... In the above you can tell the customer with an id of 2 has a favorite color ...
    (microsoft.public.access.gettingstarted)
  • Re: Add new record automatically
    ... a record in the parent table. ... methods to add related records to any child table, ... combobox control bound to the foreign key field, ... with a couple different options on providing the primary key value of the ...
    (microsoft.public.access.forms)
  • Re: How to deal with cascading changes?
    ... I have two tables: Parent and Child. ... This primary key is also part of the primary key of table Child. ... In the database the primary key will cascade to table Child. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Add new record automatically
    ... the only way two forms can be "linked" is when one is loaded into a subform ... mainform's subform control are set appropriately. ... methods to add related records to any child table, ... with a couple different options on providing the primary key value of the ...
    (microsoft.public.access.forms)
  • Re: Subform Wizard and number of primary key fields
    ... I have created two forms- one for the parent and one for the child table. ... I want to import the child table's form as a subform on the parent table's form. ... Using the Subform Wizard, everything goes well until it gets to the point where I need to specify the linking fields. ... My problem is that Access allows only up to 3 fields for linking a subform to a parent form, and that would force my having to enter manually the other 2 fields in the primary key from the parent into the child. ...
    (comp.databases.ms-access)