Subform value not entered twice...how to ?

  • Thread starter Thread starter Niko
  • Start date Start date
N

Niko

Hi,

How is it possible in a subform that picks up values from a table not
to have the same value entered twice ?

I'm fresh new to Access, sorry if it is too easy...

Thanks in advance !
 
Niko

Are you saying that you want to prevent data entry of a "duplicate" value,
via a subform? If so, one approach would be to add a unique index to that
field in the underlying table, to prevent the saving of a duplicate value.
 
Jeff Boyce said:
Niko

Are you saying that you want to prevent data entry of a "duplicate" value,
via a subform? If so, one approach would be to add a unique index to that
field in the underlying table, to prevent the saving of a duplicate value.

Hi Jeff,

What I want is every time I add a new record to the form and some
values to its subform, that values prohibited from beeing entered
twice. I don't want to make the field of the table (which the subform
looks into) to be a primary key or beeing uniquely indexed. I think
that's got to do with Expression Builder and something like if
value of subform is equal to previously entered values then error
or something like that.
The thing is that I don't now how to build such an expression cause
I'm fresh-fresh, so I could use your guidance on easy steps doing
that...

Thanks for taking the time to answer Jeff
 
Niko

If you truly do not want more than one instance of a value to be entered in
the subform (for a given mainform value), you can do this most easily by
creating an index on the field(s) of the table underlying the subform. I
don't understand why the underlying table should not be indexed.

An example may help illustrate:

If I had a one-to-many relationship between Students and StudentCourseGrade,
I would want to ensure that I only had one CourseGrade per valid combination
of Student and Course. In a relation/junction table designed like:

trelStudentCourseGrade
StudentCourseGradeID
StudentID
CourseID
Grade

I would create a unique index on StudentID AND CourseID. That way, Access
would prevent me from trying to enter a grade for the same Student & Course
after I already had one.
 
Jeff , thanks again for your time

Finally I made it !! I had to make three tables and one of them was a
junction table between a many-to-many relationship.So I checked out
the Northwind database a little bit and I found out what I had to do.
Now, I'm trying to comprehend all the logical steps someone must make
in order to preserve and develop one step ahead...

Thanks Jeff again... I'll be posting questions... not too many I hope
!!
 
Back
Top