473,402 Members | 2,055 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,402 software developers and data experts.

Report Formatting Code Issue: Working, but taking too long to open

21
I am working within a DB I have been devolping in Access 2003, and have encountered a report coding issue I was hoping someone could help me with:

I have 18 reports, each running off some smaller queried version of 2 main queries (apx. 6000 records each). The purposes of the DB and the reports require the formatting of these reports to change monthly as Actual Revenue is reported.

I can accomplish all of these monthly formatting changes based on visible true/false code. However, this code turns reports that were taking 5-7 seconds to open into reports that are taking around 2 minutes to open. (This is of course unacceptable!)

The details: There are 216 fields in the details, header, and footer, 18 of which need to be reset as visible true/false each month. I have it currently set up as 36 Private Subs (three per month, one for each details & header & footer). These are set up as 96, 96, and 24-line codes resembling the following:

Private Sub JanVisibilityDetails()
Me![JanActuals].Visible = True
Me![JanFinalProj].Visible = True
Me![JanDiffAct].Visible = True
Me![JanDiffPercAct].Visible = True
Me![JanProjC].Visible = False
.....

The Visible True/False setting are listed for each of the 216 fields in each Sub.

These are then called with Case "" statements, such as:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Select Case Me![Month]
Case "Jan"
Call JanVisibilityDetails
Case "Feb"
Call FebVisibilityDetails
.....


This is all done within the Report Code of each individual report.


I have tried various adjustments, like having the code under each Format Sub case, rather than having each case call a separate Private Sub. Same speed. I changed the report to be looking up a table, and no change to speed. Even just having only the current month's Visible True/False code (without any select case) is still ridiculously slow. So I'm pretty sure it's the 216 lines of formatting code that is slowing everything down, but I'm not sure how to fix this. I'm currently changing visibility by hand in the reports, but I'd really like some kind of automated solution.

I'm a trial-and-error, self-taught user who is still relatively new to VB programming code and DB development. Any help anyone can give me would be very much appreciated.

Thanks!
Carrie
Mar 16 '07 #1
5 3046
Denburt
1,356 Expert 1GB
Try putting your code in the open event if you put it in the format event then it will call the code many many more times and this may not be necesary. From what it appears I think your code would only need to run once.

Private Sub Report_Open(Cancel As Integer)
Mar 16 '07 #2
CarrieR
21
Thank you, that certainly solved the problem of speed.

Unfortunately, I now have a different problem. I need to set each monthly set of Visibility True/False codes separately, or I get an error that the code is too long (I can give the exact wording, if necessary). So I'm using a Select Case to call each month's coding (named SetVisible[monthname]), based on the field in the report of "Month" (Control Source and Name):

Private Sub Report_Open(Cancel As Integer)
Select Case Me![Month]
Case "Jan"
Call SetVisibleJan
Case "Feb"
Call SetVisibleFeb
End Select
End Sub

The error I'm getting is "Run-time error '2427': You entered an expression that has no value." When Debug is hit, it takes me to the "Select Case Me![Month]", and from experimenting, I know that if I remove the Select Case language and just have one of the Call lines, that the report opens.
I know this is a relatively standard error, but I can't figure out what went wrong between this as a Report_Open Sub vs being a Format Sub, when the same code worked. Is this a certain setting of Report_Open Event Procedures I have to work around somehow? Or is something else wrong?
Mar 16 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
You can't refer to a control in the open event. Is the month always the current month or the previous month. If so you could use

Expand|Select|Wrap|Line Numbers
  1. Format(Month(Date()),"mmm") 
to get the current month. Otherwise you will need to set a global variable and pass the Month value through to the report.

Mary
Mar 16 '07 #4
CarrieR
21
Thanks everyone -- problem solved!

Took a while to figure out the exact coding for setting Global Variables (Microsoft Access Help Files don't even seem to mention them), but it all works perfectly now.
Mar 19 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
Thanks everyone -- problem solved!

Took a while to figure out the exact coding for setting Global Variables (Microsoft Access Help Files don't even seem to mention them), but it all works perfectly now.
Glad you got it working Carrie.
Mar 20 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

87
by: expertware | last post by:
Dear friends, My name is Pamela, I know little about CSS, but I would like to ask a question I have an image on a web page within a css layer: <DIV ID=MyLayer STYLE = "position:...
14
by: expertware | last post by:
Ok! to avoid confusion I will start a new argument. Thanks!! FIREFOX 1.0.7 AND IE6 viewed through DATATIME: a summary REPORT ===============================================================...
7
by: Georges Heinesch | last post by:
Hi. I have a problem with alternating background colors in a report. The code below shows, that the first line should always be white (default global boolean value is false). However it depends...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
5
by: bcanavan | last post by:
When I export xml(and xls) from Access 2003 the result is a complete report in a single page. I would like to get the entire report in a single page (one trip to the server) for printing and...
171
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
4
by: lupo666 | last post by:
Hi everybody, this time I have three problems driving me nuts :-((( (1) I have a report with 20 or so Yes/No "squares". Is there a way to either hide/show the "square" or change the yes/no...
10
by: sara | last post by:
Hi - I have a report that is 14 columnar sub-reports (Line up: Position- holders in each of our 14 locations - Manager, Assistant Manager, Receiving, Office, etc). I output directly to PDF...
4
by: J Lagos | last post by:
I want to change the backcolor of textboxes in a report depending on their value. I messed with this for a few hours but I'm not savvy with the syntax for getting at controls in a report. can...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.