Bill Benson
bensonforums at gmail.com
Thu Jan 1 16:26:38 CST 2015
You know, there was a really slick consequence from this query. Not only
did it enable me to sequence all the entered phone/phone type items *by
company*, in the final output, but the query leaves the phone number field
updatable, which is fantastic and just what I wanted to happen. One
negative is that it also makes the phonetype updatable (note, phonetypeid
is not updatable). I really don't want the user able to change the
phonetype (which is a description field) while editing phone numbers. So I
had to be careful to lock the phonetype field on the form.
SELECT
B.PhonePhoneTypeID,A.FKCompanyID AS CompanyID,
DCount("PhonePhoneTypeID","PhonePhoneTypes","PhonePhoneTypeID<=" &
B.PhonePhoneTypeID & " And FKCompanyPhoneID In (Select CompanyPhoneID From
Phone Where Phone.FKCompanyID = " & A.FKCompanyID & ")") AS Item,
A.Phone,
C.PhoneTypeID,C.PhoneType
FROM PhoneType AS C RIGHT JOIN (Phone AS A INNER JOIN PhonePhoneTypes AS B
ON A.CompanyPhoneID = B.FKCompanyPhoneID) ON C.PhoneTypeID =
B.FKPhoneTypeID ORDER BY B.PhonePhoneTypeID;