[AccessD] Increment Child #s

David McAfee davidmcafee at gmail.com
Wed Nov 17 13:42:58 CST 2010


Can you do it via a query? Something like:

SELECT
	(select count(*)
	 from tblParent as T1
	 where T1.PKID<=tblParent .PKID) AS LineNum,
	tblParent .PKID,
	tblParent .CompanyName
FROM tblParent
ORDER BY tblParent .PKID;


On Wed, Nov 17, 2010 at 10:56 AM, Arthur Fuller <fuller.artful at gmail.com> wrote:
> Assume:
>
> T1 - parent file, say CustomerOrders
> T2 - child file, say CustomerOrderItems
>
> Goal:
>
> Inherit the PK from T1, but add an Item# column that enumerates the Items on
> said Order, so...
>
> CO1
>    Item 1
>    Item 2
> CO2
>    Item 1
>    Item 2
>
> I wrote some code to do a Dmax() call using the Parent PK but yuk! I'm
> trying to find a slicker way to do this, ideally so that I can default the
> Item# value for the next new record. Any ideas how this might be done?
>
> TIA
> A.
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>




More information about the AccessD mailing list