From: Marianne on
Thanks to everyone for all your info and suggestions. I think I shall try the
vb code approach and see if I can make that work.

"Arvin Meyer [MVP]" wrote:

> It's a lot easier to do in VBA code while you are creating the records.
>
> It can still be done. but I don't see how a query would do it. In code,
> you'd build a recordset sorting on the InvID, then walk through the
> recordset, adding 1 to LinNum, until InvID changes, then start with 1 again.
> --
> Arvin Meyer, MCP, MVP
> http://www.datastrat.com
> http://www.mvps.org/access
> http://www.accessmvp.com
>
>
> "Marianne" <Marianne(a)discussions.microsoft.com> wrote in message
> news:2BA6B347-41C4-405E-AD19-10329852E960(a)microsoft.com...
> > Can this task be accomplished through an update query?
> >
> > I want to number the lines for an existing database. There are 13K+
> > records
> > in table A.
> >
> > I have a query using the count function which returns the correct number
> > of
> > lines for each InvID, but how do I update each line with the correct
> > number,
> > 1,2,3 etc?
> >
> > Table A has a one-to-many relationship with Table B. The primary key
> > fields
> > are Table A.InvID and Table B.DetInvID I have added a field [LineNum] to
> > Table B. [LineNum] should increment starting at 1 for each InvID.
> >
> > TableB.InvID TableB.LineNum
> >
> > 555 1
> >
> > 555 2
> >
> > 555 3
> >
> > 556 1
> >
> > 557 1
> >
> > 557 2
> >
> >
> >
> > Assistance is greatly appreciated!
> >
> > Marianne
> >
> >
>
>
> .
>