473,245 Members | 1,648 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,245 software developers and data experts.

Report Module Problems

I have a report that I created that has no data, just boxes, lines and one
date field not tied to anything. Basically this report will just print
pages according to the dates you entered. Then according to the day, it
will hide certain boxes.

Here is the code (BELOW) I've drummed up, but how do I use it to print out a
range of pages?

THANKS

Jim

Private Sub Report_Page()
Dim DDate As Date, StartDay As Date, EndDay As Date

StartDay = InputBox("What is the first day you'd like to print?", "START")
EndDay = InputBox("What is the last day you'd like to print?", "FINISH")

DDate = StartDay

Do Until DDate = EndDay + 1

Me![B1].Visible = True
Me![B2].Visible = True
Me![B3].Visible = True
Me![B4].Visible = True
Me![B10].Visible = True
Me![B11].Visible = True
If Format(DDate, "DDD") = "Sun" Then
DDate = DDate + 1
ElseIf Format(DDate, "DDD") = "Mon" Or Format(DDate, "DDD") = "Thu" Then
Me![TheDate] = DDate
Me![B10].Visible = False
Me![B11].Visible = False
Me![B1].Visible = False
Me![B2].Visible = False
Me![B3].Visible = False
Me![B4].Visible = False
ElseIf Format(DDate, "DDD") = "Tue" Then
Me![TheDate] = DDate
Me![B10].Visible = False
Me![B2].Visible = False
Me![B3].Visible = False
Me![B4].Visible = False
ElseIf Format(DDate, "DDD") = "Wed" Then
Me![TheDate] = DDate
Me![B1].Visible = False
Me![B2].Visible = False
Me![B3].Visible = False
Me![B4].Visible = False
Else
Me![TheDate] = DDate
End If

DDate = DDate + 1

Loop
End Sub
Nov 12 '05 #1
5 3157
Jim Fox wrote:
I have a report that I created that has no data, just boxes, lines and one
date field not tied to anything. Basically this report will just print
pages according to the dates you entered. Then according to the day, it
will hide certain boxes.

Here is the code (BELOW) I've drummed up, but how do I use it to print out a
range of pages?

Private Sub Report_Page()
Dim DDate As Date, StartDay As Date, EndDay As Date

StartDay = InputBox("What is the first day you'd like to print?", "START")
EndDay = InputBox("What is the last day you'd like to print?", "FINISH")

DDate = StartDay

Do Until DDate = EndDay + 1

Me![B1].Visible = True
Me![B2].Visible = True
Me![B3].Visible = True
Me![B4].Visible = True
Me![B10].Visible = True
Me![B11].Visible = True
If Format(DDate, "DDD") = "Sun" Then
DDate = DDate + 1
ElseIf Format(DDate, "DDD") = "Mon" Or Format(DDate, "DDD") = "Thu" Then
Me![TheDate] = DDate
Me![B10].Visible = False
Me![B11].Visible = False
Me![B1].Visible = False
Me![B2].Visible = False
Me![B3].Visible = False
Me![B4].Visible = False
ElseIf Format(DDate, "DDD") = "Tue" Then
Me![TheDate] = DDate
Me![B10].Visible = False
Me![B2].Visible = False
Me![B3].Visible = False
Me![B4].Visible = False
ElseIf Format(DDate, "DDD") = "Wed" Then
Me![TheDate] = DDate
Me![B1].Visible = False
Me![B2].Visible = False
Me![B3].Visible = False
Me![B4].Visible = False
Else
Me![TheDate] = DDate
End If

DDate = DDate + 1

Loop
End Sub


You can not use the Page event to do this.

Move the Dim statement to the report module's declaration
section to make them module level variables.

Place the code to set the initial values of variables in the
report's Open event.

Then use the Detail section Format event to make the text
boxes visible, etc. Discard the Do loop and use this kind
of logic:

Sub Detail_Format( . . .
Me![B1].Visible = True
. . .
DDate = DDate + 1
If DDate < EndDay Then
Me.NextRecord = False
End If
End Sub

You should also beef up the code to get the dates by
checking to make sure the user really entered valid dates,
that the start date is earlier than the end date and that
the end date is not too far out in the future.

--
Marsh
MVP [MS Access]
Nov 12 '05 #2
"Jim Fox" <ji****@chartermi.net> wrote in message
news:vl************@corp.supernews.com...
I have a report that I created that has no data, just boxes, lines and one
date field not tied to anything. Basically this report will just print
pages according to the dates you entered. Then according to the day, it
will hide certain boxes.

Here is the code (BELOW) I've drummed up, but how do I use it to print out a range of pages?

THANKS

Jim

Private Sub Report_Page()
Dim DDate As Date, StartDay As Date, EndDay As Date

StartDay = InputBox("What is the first day you'd like to print?", "START")
EndDay = InputBox("What is the last day you'd like to print?", "FINISH")

DDate = StartDay

Do Until DDate = EndDay + 1

Me![B1].Visible = True
Me![B2].Visible = True
Me![B3].Visible = True
Me![B4].Visible = True
Me![B10].Visible = True
Me![B11].Visible = True
If Format(DDate, "DDD") = "Sun" Then
DDate = DDate + 1
ElseIf Format(DDate, "DDD") = "Mon" Or Format(DDate, "DDD") = "Thu" Then Me![TheDate] = DDate
Me![B10].Visible = False
Me![B11].Visible = False
Me![B1].Visible = False
Me![B2].Visible = False
Me![B3].Visible = False
Me![B4].Visible = False
ElseIf Format(DDate, "DDD") = "Tue" Then
Me![TheDate] = DDate
Me![B10].Visible = False
Me![B2].Visible = False
Me![B3].Visible = False
Me![B4].Visible = False
ElseIf Format(DDate, "DDD") = "Wed" Then
Me![TheDate] = DDate
Me![B1].Visible = False
Me![B2].Visible = False
Me![B3].Visible = False
Me![B4].Visible = False
Else
Me![TheDate] = DDate
End If

DDate = DDate + 1

Loop
End Sub


If you are using A2K2 then you could use the reports OpenArgs, if not you
could define a global variable (g_dteDDate) which is processed in the
report's OpenEvent.

Private Sub Report_Open(Cancel As Integer)

Select Case DatePart("d", g_dteDDate, vbMonday)
Case 1
' Do Monday Stuff
Case 2
' Do Tuesday Stuff
Case 3
' Do Wednesday Stuff
' Etc
End Select

End Sub
Then in your loop, increment the date and print out the report:

g_dteDDate = g_dteDDate + 1
DoCmd.OpenReport "MyReport"
Nov 12 '05 #3
"Marshall Barton" <ma*********@wowway.com> wrote in message
news:a4********************************@4ax.com...
Jim Fox wrote:
I have a report that I created that has no data, just boxes, lines and onedate field not tied to anything. Basically this report will just print
pages according to the dates you entered. Then according to the day, it
will hide certain boxes.

Here is the code (BELOW) I've drummed up, but how do I use it to print out arange of pages?

Private Sub Report_Page()
Dim DDate As Date, StartDay As Date, EndDay As Date

StartDay = InputBox("What is the first day you'd like to print?", "START")EndDay = InputBox("What is the last day you'd like to print?", "FINISH")

DDate = StartDay

Do Until DDate = EndDay + 1

Me![B1].Visible = True
Me![B2].Visible = True
Me![B3].Visible = True
Me![B4].Visible = True
Me![B10].Visible = True
Me![B11].Visible = True
If Format(DDate, "DDD") = "Sun" Then
DDate = DDate + 1
ElseIf Format(DDate, "DDD") = "Mon" Or Format(DDate, "DDD") = "Thu" Then Me![TheDate] = DDate
Me![B10].Visible = False
Me![B11].Visible = False
Me![B1].Visible = False
Me![B2].Visible = False
Me![B3].Visible = False
Me![B4].Visible = False
ElseIf Format(DDate, "DDD") = "Tue" Then
Me![TheDate] = DDate
Me![B10].Visible = False
Me![B2].Visible = False
Me![B3].Visible = False
Me![B4].Visible = False
ElseIf Format(DDate, "DDD") = "Wed" Then
Me![TheDate] = DDate
Me![B1].Visible = False
Me![B2].Visible = False
Me![B3].Visible = False
Me![B4].Visible = False
Else
Me![TheDate] = DDate
End If

DDate = DDate + 1

Loop
End Sub


You can not use the Page event to do this.

Move the Dim statement to the report module's declaration
section to make them module level variables.

Place the code to set the initial values of variables in the
report's Open event.

Then use the Detail section Format event to make the text
boxes visible, etc. Discard the Do loop and use this kind
of logic:

Sub Detail_Format( . . .
Me![B1].Visible = True
. . .
DDate = DDate + 1
If DDate < EndDay Then
Me.NextRecord = False
End If
End Sub

You should also beef up the code to get the dates by
checking to make sure the user really entered valid dates,
that the start date is earlier than the end date and that
the end date is not too far out in the future.

--
Marsh
MVP [MS Access]


Hi Marsh

Will this not be difficult if the report is not bound to any data at all?
One idea, he could try would be to use your suggestion but insert the
required dates into a temporary table before opening the report. At least
then the report would be bound and this might be a better solution than my
first suggestion (which would be difficult to print preview multiple days)

Fletcher
Nov 12 '05 #4
>> Jim Fox wrote:
>I have a report that I created that has no data, just boxes, lines andone >date field not tied to anything. Basically this report will just print
>pages according to the dates you entered. Then according to the day, it
>will hide certain boxes.
>
>Here is the code (BELOW) I've drummed up, but how do I use it to print
>out a range of pages?
>
>Private Sub Report_Page()
>Dim DDate As Date, StartDay As Date, EndDay As Date
>
>StartDay = InputBox("What is the first day you'd like to print?","START") >EndDay = InputBox("What is the last day you'd like to print?", "FINISH")
>
>DDate = StartDay
>
>Do Until DDate = EndDay + 1
>
> Me![B1].Visible = True [snip repetitive code] > End If
>
> DDate = DDate + 1
>
>Loop
>End Sub

"Marshall Barton" wrote
You can not use the Page event to do this.

Move the Dim statement to the report module's declaration
section to make them module level variables.

Place the code to set the initial values of variables in the
report's Open event.

Then use the Detail section Format event to make the text
boxes visible, etc. Discard the Do loop and use this kind
of logic:

Sub Detail_Format( . . .
Me![B1].Visible = True
. . .
DDate = DDate + 1
If DDate < EndDay Then
Me.NextRecord = False
End If
End Sub

You should also beef up the code to get the dates by
checking to make sure the user really entered valid dates,
that the start date is earlier than the end date and that
the end date is not too far out in the future.


Fletcher Arnold wrote:Will this not be difficult if the report is not bound to any data at all?
One idea, he could try would be to use your suggestion but insert the
required dates into a temporary table before opening the report. At least
then the report would be bound and this might be a better solution than my
first suggestion (which would be difficult to print preview multiple days)


Having a table of dates and using a parameter query to
select the desired range is a good way to do this as long as
that table is not difficult to manage. However, an unbound
report as I described will work quite nicely without any
additional mechanisms.

An unbound report will print one detail section and the
NextRecord=False will cause it to process that section
repeatedly until NextRecord is left in its default True
state. This can be a very powerful tool in those very rare
situations where you want to print a lot of calculated
values (including handling recordsets that can not be made
to live within the standard Access report limitations).

--
Marsh
Nov 12 '05 #5
"Marshall Barton" <ma*********@wowway.com> wrote in message

Having a table of dates and using a parameter query to
select the desired range is a good way to do this as long as
that table is not difficult to manage. However, an unbound
report as I described will work quite nicely without any
additional mechanisms.

An unbound report will print one detail section and the
NextRecord=False will cause it to process that section
repeatedly until NextRecord is left in its default True
state. This can be a very powerful tool in those very rare
situations where you want to print a lot of calculated
values (including handling recordsets that can not be made
to live within the standard Access report limitations).

Thanks for the reply - I'm glad I asked. That's a technique I've never used
before but can imagine it being something useful to keep in my bag of
tricks. I did just try it to make sure I could print out 10 'records' by
using this code:

lng = lng + 1
If lng < 10 Then Me.NextRecord = False

But being the end of a hard day I had Dim lng as Long in the sub itself
(duhh) - so you can imagine the wait to see the last page!

Regards

Fletcher

Nov 12 '05 #6

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

Similar topics

3
by: Nicola | last post by:
Hi Everyone, I am new to programming and would like to know how to open an access Report from within vb 6. I am trying to write a program to organise cross stitch threads. I have found out how...
1
by: Gudni G. Sigurdsson | last post by:
Hi. I am working on a program for the .NET Framework written in C# with Visual Studio .NET. With this program, one can print a report realized with the Crystal Report software included with VS...
3
by: Ranman | last post by:
Hi all, I have a simple problem that hopefully has a simple solution, but I have yet to figure it out. In a patient database, I have a physician test order form that populates a report that is...
6
by: Bob Alston | last post by:
I am looking for Access reporting add-in that would be easy to use by end users. My key focus is on selection criteria. I am very happy with the Access report writer capabilities. As far as...
7
by: MLH | last post by:
The Me object in A97 HELP is associated with forms. I've used Me.Name with success in a report's Open event code successfully. However, I seem to recall occasions where use of Me in report...
3
by: T | last post by:
I'm trying to determine the useage of varioius reports I have. I need the following to occur when a report is opened, get the name of the report, datetime, username. I created a tblLog...
1
by: AMD_GAMER | last post by:
Hi, I am trying to print address labels. I have a form which asks for the user to input the first name, middle initial, and last name. On the button click to print the label, I have an event...
1
by: Tomizechsterson | last post by:
I have an app, that when it calls ReportDocument.Load(filename), it throws an Exception that just says "Load report failed." Upon further investigation, the ErrorCode is -2147483136, the...
11
by: Gord | last post by:
When I open a certain report, it runs some code that generates the records that will be displayed in that report. This works fine. When I go to print preview the report it appears that the code...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.