473,379 Members | 1,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Table of Contents stopped working (MDB -> ADP)

I have a report laid out in Design View as shown at the end of this message.

I have code that performs the following steps:

1. In main report's Report_Open(), DELETE any old rows in tblTOC for
this username.
2. In main report's CategoryHeader_Format(), add a row to tblTOC with
the current category name and the current page number.
3. In the table of contents subreport, Cancel if NoData event fires.

When this report was in an MDB file, if Text12 had the datasource =
"[Page] of [Pages]" the report would run through the code for all the
data and properly fill in tblTOC with page numbers each time the
CategoryHeader_Format() event fired. So that when the page with
FormVersionHeader on it was viewed, the table of contents would be
properly displayed.

I upsized this database to a SQL server backend / ADP front end and now
the page with FormVersionHeader on it is blank. My assumption is that
the report cancels the first time through because tblTOC is blank.
However, in the MDB file, once the report was open in preview mode, the
table of contents would get filled in the second time you navigated to
the page with FormVersionHeader on it. This second rendering doesn't
seem to be happening in the ADP file. Does anyone have any suggestions
on why this might occur?

Code snippets:

rptMain:

Private Sub Report_Open(Cancel as Integer)
' Setup the table of contents
If UCase(Me.ShowTOC.Caption) <> "Y" Then
With Me
.Text12.ControlSource = "=""Page "" & [Page]"
.grpFormVersionHeader.Visible = False
End With
Else
With Me
.Text12.ControlSource = "=""Page "" & [Page] & "" of "" & [Pages]"
.grpFormVersionHeader.Visible = True
End With

' Clear out old table of contents
Set cmd = New ADODB.Command
With cmd
Set .ActiveConnection = Application.CurrentProject.Connection
.CommandType = adCmdText
.CommandText = "DELETE FROM " & sTOC_TABLE & " WHERE
Username='" & sUsername & "'"
.Execute
End With
Set cmd = Nothing
End If

End Sub

Private Sub grpCategoryHeader_Format(Cancel As Integer, FormatCount As
Integer)

' Update the table of contents, if necessary
If UCase(Me.ShowTOC.Caption) = "Y" Then
AddToTOC sTOC_TABLE, sUsername, CStr(Me.txtCategoryHeader),
CLng(Me.Page)
End If

End Sub

Public Sub AddToTOC(sTocTable As String, sUsername As String, sText As
String, lPageNumber As Long)

Dim rs As ADODB.Recordset
Dim sTableEntry As String

Set rs = New ADODB.Recordset
With rs

Set .ActiveConnection = Application.CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockOptimistic

.Open "SELECT * FROM " & sTocTable & " WHERE Username='" &
sUsername & "'"

' Save category name
sTableEntry = Mid(Trim(sText), 1, .Fields("TableEntry").DefinedSize)
.Filter = "TableEntry='" & sTableEntry & "'"

' If we haven't stored the pagenumber yet, save it to the table
If .RecordCount = 0 Then
.AddNew
.Fields("TableEntry").Value = sTableEntry
.Fields("PageNumber").Value = lPageNumber
.Fields("Username").Value = sUsername
.Update
End If

.Filter = adFilterNone
.Close
End With
Set rs = Nothing
End Sub

rptTOC:

Private Sub Report_NoData(Cancel As Integer)
Cancel = CInt(True)
End Sub

Report layout:

ReportHeader - acts as a cover sheet
------------
Label1 - datestamp
Label2 - database path

FormVersionHeader (FormVersion is a date stamp, all records in
recordsource have the same value)
---------

Subreport1 - based on the table of contents report, which is based on
the table, tblTOC.

CategoryHeader
---------------
Textbox1 - Displays category name in bold

ItemHeader
----------
Textbox2 - Item name
Textbox3 - Item description

Detail
------
contains several subreports that show details about the item

PageFooter
----------

Textbox12 - contains the page number info
Jan 12 '06 #1
1 2169
I've been fiddling around with the table of contents some more.
It still does not show up in the print preview, but when the data is
finally printed, the table shows up.

The only thing I can figure is that an ADP file will cache table data to
cut down on network traffic. Some the main report opens up, then the
table of contents sub-report is opened and its data is pulled. However,
since we just opened the main report, the recordsource for the subreport
is empty. Then after the report has finished loading in print preview,
the data is not fetched again when I navigate to page 2 (which is the
page with the table of contents on it). In the MDB file, the data for a
page is fetched everytime you navigate to it (or at least more
frequently) than it is in an ADP file.

Beowulf wrote:
I have a report laid out in Design View as shown at the end of this
message.

I have code that performs the following steps:

1. In main report's Report_Open(), DELETE any old rows in tblTOC for
this username.
2. In main report's CategoryHeader_Format(), add a row to tblTOC with
the current category name and the current page number.
3. In the table of contents subreport, Cancel if NoData event fires.

When this report was in an MDB file, if Text12 had the datasource =
"[Page] of [Pages]" the report would run through the code for all the
data and properly fill in tblTOC with page numbers each time the
CategoryHeader_Format() event fired. So that when the page with
FormVersionHeader on it was viewed, the table of contents would be
properly displayed.

I upsized this database to a SQL server backend / ADP front end and now
the page with FormVersionHeader on it is blank. My assumption is that
the report cancels the first time through because tblTOC is blank.
However, in the MDB file, once the report was open in preview mode, the
table of contents would get filled in the second time you navigated to
the page with FormVersionHeader on it. This second rendering doesn't
seem to be happening in the ADP file. Does anyone have any suggestions
on why this might occur?

Code snippets:

rptMain:

Private Sub Report_Open(Cancel as Integer)
' Setup the table of contents
If UCase(Me.ShowTOC.Caption) <> "Y" Then
With Me
.Text12.ControlSource = "=""Page "" & [Page]"
.grpFormVersionHeader.Visible = False
End With
Else
With Me
.Text12.ControlSource = "=""Page "" & [Page] & "" of "" & [Pages]"
.grpFormVersionHeader.Visible = True
End With

' Clear out old table of contents
Set cmd = New ADODB.Command
With cmd
Set .ActiveConnection = Application.CurrentProject.Connection
.CommandType = adCmdText
.CommandText = "DELETE FROM " & sTOC_TABLE & " WHERE Username='"
& sUsername & "'"
.Execute
End With
Set cmd = Nothing
End If

End Sub

Private Sub grpCategoryHeader_Format(Cancel As Integer, FormatCount As
Integer)

' Update the table of contents, if necessary
If UCase(Me.ShowTOC.Caption) = "Y" Then
AddToTOC sTOC_TABLE, sUsername, CStr(Me.txtCategoryHeader),
CLng(Me.Page)
End If

End Sub

Public Sub AddToTOC(sTocTable As String, sUsername As String, sText As
String, lPageNumber As Long)

Dim rs As ADODB.Recordset
Dim sTableEntry As String

Set rs = New ADODB.Recordset
With rs

Set .ActiveConnection = Application.CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockOptimistic

.Open "SELECT * FROM " & sTocTable & " WHERE Username='" & sUsername
& "'"

' Save category name
sTableEntry = Mid(Trim(sText), 1, .Fields("TableEntry").DefinedSize)
.Filter = "TableEntry='" & sTableEntry & "'"

' If we haven't stored the pagenumber yet, save it to the table
If .RecordCount = 0 Then
.AddNew
.Fields("TableEntry").Value = sTableEntry
.Fields("PageNumber").Value = lPageNumber
.Fields("Username").Value = sUsername
.Update
End If

.Filter = adFilterNone
.Close
End With
Set rs = Nothing
End Sub

rptTOC:

Private Sub Report_NoData(Cancel As Integer)
Cancel = CInt(True)
End Sub

Report layout:

ReportHeader - acts as a cover sheet
------------
Label1 - datestamp
Label2 - database path

FormVersionHeader (FormVersion is a date stamp, all records in
recordsource have the same value)
---------

Subreport1 - based on the table of contents report, which is based on
the table, tblTOC.

CategoryHeader
---------------
Textbox1 - Displays category name in bold

ItemHeader
----------
Textbox2 - Item name
Textbox3 - Item description

Detail
------
contains several subreports that show details about the item

PageFooter
----------

Textbox12 - contains the page number info

Jan 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steve_EE | last post by:
I'm running phpMyAdmin 2.5.3 / MySQL 4.0.14 / PHP 4.3.3 / Apache 1.3.20 phpMyAdmin is installed and appears ok at first, I can login, select databases, view which tables are in each db, see the...
10
by: tHatDudeUK | last post by:
My form action code to submit values to itself have stopped working using the code form action = <?=$_SERVER?> This code used to work My web host recently told me they enabled phpsuexec...
5
by: Bill | last post by:
I used to be able to run the following ASP code on our corp machine (W2K Server Edition and IIS-5) and successfully send a net-msg to anyone on our intranet. Last week it stopped working... and...
4
by: Dag Sunde | last post by:
I've been working on a system that have been running for the last couple of years, but stopped working on my dev. machine after reinstalling WinXP yesterday. To my knowledge, it have been set up...
2
by: Dag Sunde | last post by:
I have the following code fragment in one of my pages: if (typeof document.getElementById('myApplet').getTableAsSDV != 'undefined') { rowBuffer =...
7
by: brett valjalo | last post by:
Hey Folks: Long time no see! Hope everyone is well. I have an old mdb I'm upsizing to an adp. There is a button on a form which executes code similar to the following (this is a search form...
1
by: Mark | last post by:
Hi - on my site, overnight, my submit buttons have suddenly stopped working in IE. Firefox is fine. The link button works perfectly - the two submit buttons however do not. It works in IE...
1
by: rickcasey | last post by:
I wonder if anyone has experienced something like this, as it seems truly bizarre and is causing me to tear out my hair (what little there is left of it).... The exec() function just suddenly...
2
by: jkych | last post by:
Hi, A sample code as below: Private Sub codetesting() Dim rs As DAO.Database Set rs = CurrentDb MsgBox (rs.Name) End Sub
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.