G
Guest
I need to locate the last page number in an "Indexes" table that I have and
then use it as the beginning number in a second module. The "Indexes" table
has two fields, a description and page number.
Specifically I am unclear what the 1st argument in the CreateQueryDef should
be. I have "PageNumberLast" in the CreateQueryDef but I this can't be
correct. I thought that I would actually be creating this variable that I
could then use to reset the page count (intPageCounter).
Here is what I have tried (I tried to supply only what we need):
Dim db5 As DAO.Database
Dim intPageCounter as Integer
Dim intLastPageNo as Integer
Dim strSQL as String
Function InitToc3()
'Called from the OnOpen property of the report.
Dim qd5 As DAO.QueryDef
Set db5=CurrentDB()
'Set the page number to the last page used in the "Indexes" table (I believe
this is were my problems begin)
strSQL="Select Max(Indexes,[PageNumber] from [Indexes]'
Set qd5=db5.CreateQueryDef("PageNumberLast",strSQL)
qd5.Execute
qd5.Close
intPageCounter=PageNumberLast
I was hoping to have a query that would identify the maximum page number in
the "Indexes" table and then use that to set "intPageCounter"
I am a newbie, but learning lots. If there is an easier way I open to making
life simplier.
then use it as the beginning number in a second module. The "Indexes" table
has two fields, a description and page number.
Specifically I am unclear what the 1st argument in the CreateQueryDef should
be. I have "PageNumberLast" in the CreateQueryDef but I this can't be
correct. I thought that I would actually be creating this variable that I
could then use to reset the page count (intPageCounter).
Here is what I have tried (I tried to supply only what we need):
Dim db5 As DAO.Database
Dim intPageCounter as Integer
Dim intLastPageNo as Integer
Dim strSQL as String
Function InitToc3()
'Called from the OnOpen property of the report.
Dim qd5 As DAO.QueryDef
Set db5=CurrentDB()
'Set the page number to the last page used in the "Indexes" table (I believe
this is were my problems begin)
strSQL="Select Max(Indexes,[PageNumber] from [Indexes]'
Set qd5=db5.CreateQueryDef("PageNumberLast",strSQL)
qd5.Execute
qd5.Close
intPageCounter=PageNumberLast
I was hoping to have a query that would identify the maximum page number in
the "Indexes" table and then use that to set "intPageCounter"
I am a newbie, but learning lots. If there is an easier way I open to making
life simplier.