C
Carlos1815
Hello, all! I have a problem that from the outset seems easy,
and there's plenty of information on here and other forums on the
subject, but nothing that answers my question.
I have a form with a control called PageID whose control source is a
table with a PageID field; it is not an autonumber, I've been very
well briefed on autonumber's strengths and limitations! The form is
an interface where a designer can enter data, text, graphics,
questions, etc., and the corresponding table of data is read by
Authorware. Each record is a page in Authorware, and the PageID is
the page number. If the designer adds a new page, the PageID is
incremented up using the following code:
Private Sub Form_Current()
If Me.NewRecord Then
Me.PageID = Nz(DMax("PageID", "Topic1") + 1, 1)
DoCmd.RunCommand acCmdRefresh
End If
End Sub
That works fine. However, if a page is deleted in the middle of the
db, like page 3 of 5, then the pages are numbered thusly:
From:
PageID
1 Page 1
2 Page 2
3 Page 3 <-- delete this page
4 Page 4 <-- make this page 3
5 Page 5 <-- make this page 4
To:
PageID
1 Page 1
2 Page
2
4 <-- oops! Page 3
5 Page 4
So when I take out page 3, page 4 becomes page 3 and so on down the
line. But what I would like is for the PageID number to renumber
itself so there are no gaps in the PageID field. Maybe some sort of
code in AfterUpdate() or FormCurrent() that automatically renumbers
the records after one is deleted. The deletion, by the way, occurs
through a command button I created. I know that not ALL the numbers
have to be redone, just the ones below the record that was deleted. I
can't figure out how to make that happen; any help would be
appreciated!! Thanks in advance!
Carlos
and there's plenty of information on here and other forums on the
subject, but nothing that answers my question.
I have a form with a control called PageID whose control source is a
table with a PageID field; it is not an autonumber, I've been very
well briefed on autonumber's strengths and limitations! The form is
an interface where a designer can enter data, text, graphics,
questions, etc., and the corresponding table of data is read by
Authorware. Each record is a page in Authorware, and the PageID is
the page number. If the designer adds a new page, the PageID is
incremented up using the following code:
Private Sub Form_Current()
If Me.NewRecord Then
Me.PageID = Nz(DMax("PageID", "Topic1") + 1, 1)
DoCmd.RunCommand acCmdRefresh
End If
End Sub
That works fine. However, if a page is deleted in the middle of the
db, like page 3 of 5, then the pages are numbered thusly:
From:
PageID
1 Page 1
2 Page 2
3 Page 3 <-- delete this page
4 Page 4 <-- make this page 3
5 Page 5 <-- make this page 4
To:
PageID
1 Page 1
2 Page
2
4 <-- oops! Page 3
5 Page 4
So when I take out page 3, page 4 becomes page 3 and so on down the
line. But what I would like is for the PageID number to renumber
itself so there are no gaps in the PageID field. Maybe some sort of
code in AfterUpdate() or FormCurrent() that automatically renumbers
the records after one is deleted. The deletion, by the way, occurs
through a command button I created. I know that not ALL the numbers
have to be redone, just the ones below the record that was deleted. I
can't figure out how to make that happen; any help would be
appreciated!! Thanks in advance!
Carlos