Page 1 of 1

Lookup "many records" error

Posted: Sat Aug 22, 2015 5:30 am
by BenFranske
I have a lookup field on a subform but when I try to use it to make a selection instead of the code displaying I get a "many records" message. I believe this is because the form to lookup includes a JOIN which could result in multiple records for the same ID. However, to prevent just this problem I have limited the number of records on the form to lookup by using a GROUP BY statement in my SELECT on the form to lookup. If I manually edit the table and add the records the Lookup code field in the subform actually shows the correct value, I am just unable to set or update it through the form UI.

The form to lookup is using this SQL:
SELECT peopleID, fulltext_name FROM (
SELECT peopleID, people_name.fulltext_name FROM people
JOIN people_name on people_name.person_id = people.peopleID
ORDER BY people_name.date_effective DESC, people_name.peopleNameID DESC) AS a
GROUP BY peopleID

The Lookup ID field is peopleID and code field is fulltext_name. Given the "GROUP BY people id" statement there should never be multiple records for the same peopleID.

Any ideas on how to fix this?

Re: Lookup "many records" error

Posted: Mon Aug 24, 2015 5:49 am
by admin
Ben,

Create a View that does the grouping and use that.

Steven

Re: Lookup "many records" error

Posted: Mon Aug 24, 2015 6:20 am
by BenFranske
Interesting thought, I'll give that a try and see how it goes. Thanks!

Re: Lookup "many records" error

Posted: Fri Sep 04, 2015 3:36 am
by admin
.