A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Problem with code to draw lines for blank fields



 
 
Thread Tools Display Modes
  #1  
Old August 2nd, 2007, 03:12 PM posted to microsoft.public.access.reports
Michael[_12_]
external usenet poster
 
Posts: 75
Default Problem with code to draw lines for blank fields

Hello everyone,

I need to be able to have 28 text boxes, rectangles, etc.... anything that
will make between 1 and 28 rectangles so that if I have less than 28 checks
there will still be 28 boxes (i.e. 2 checks = 26 blank text boxes, 4 checks
= 24 blank text boxes, etc...).

Duane gave me this code:

Private Sub Report_Page()
Dim intNumLines As Integer
Dim intLineNumber As Integer
Dim intTopMargin As Integer
Dim ctl As Control
Dim intLineHeight As Integer
Dim intLineLeft As Integer
Dim intLineWidth As Integer
intNumLines = 26
intLineLeft = 720 '1/2 inch from left margin
intLineWidth = 1440 * 5 '5 inches
intTopMargin = Me.Section(3).Height
intLineHeight = Me.Section(0).Height
Me.FontSize = 14
For intLineNumber = 0 To intNumLines - 1
Me.CurrentX = intLineLeft
Me.CurrentY = intTopMargin + _
(intLineNumber * intLineHeight)
Me.Print intLineNumber + 1
Me.Line (intLineLeft, intTopMargin + _
(intLineNumber * intLineHeight)) _
-Step(intLineWidth, 0)
Next
End Sub

But it gives me an error when I use it.

Error title Microsoft Visual Basic

Run-time error '6':

Overflow.

Maybe I'm applying the code at the wrong place.

Any help? You out there Duane


  #2  
Old August 2nd, 2007, 07:01 PM posted to microsoft.public.access.reports
Marshall Barton
external usenet poster
 
Posts: 5,361
Default Problem with code to draw lines for blank fields

Michael wrote:
I need to be able to have 28 text boxes, rectangles, etc.... anything that
will make between 1 and 28 rectangles so that if I have less than 28 checks
there will still be 28 boxes (i.e. 2 checks = 26 blank text boxes, 4 checks
= 24 blank text boxes, etc...).

Duane gave me this code:

Private Sub Report_Page()
Dim intNumLines As Integer
Dim intLineNumber As Integer
Dim intTopMargin As Integer
Dim ctl As Control
Dim intLineHeight As Integer
Dim intLineLeft As Integer
Dim intLineWidth As Integer
intNumLines = 26
intLineLeft = 720 '1/2 inch from left margin
intLineWidth = 1440 * 5 '5 inches
intTopMargin = Me.Section(3).Height
intLineHeight = Me.Section(0).Height
Me.FontSize = 14
For intLineNumber = 0 To intNumLines - 1
Me.CurrentX = intLineLeft
Me.CurrentY = intTopMargin + _
(intLineNumber * intLineHeight)
Me.Print intLineNumber + 1
Me.Line (intLineLeft, intTopMargin + _
(intLineNumber * intLineHeight)) _
-Step(intLineWidth, 0)
Next
End Sub

But it gives me an error when I use it.

Error title Microsoft Visual Basic

Run-time error '6':

Overflow.



Are you sure the detail section is not too tall to display
26 times on one page.

You should use Long instead of integer just in case a line
is drawn more than 11 inches from the top of the page.

--
Marsh
MVP [MS Access]
  #3  
Old August 3rd, 2007, 03:04 PM posted to microsoft.public.access.reports
Michael[_12_]
external usenet poster
 
Posts: 75
Default Problem with code to draw lines for blank fields

It definitely has enough room because if there are more checks (up to 26)
they fit but when there's only 1 check it doesn't display the boxes I need.

I put in rectangles but even though they are of the same size as the field I
cannot get them to perfectly match up.
"Marshall Barton" wrote in message
...
Michael wrote:
I need to be able to have 28 text boxes, rectangles, etc.... anything that
will make between 1 and 28 rectangles so that if I have less than 28
checks
there will still be 28 boxes (i.e. 2 checks = 26 blank text boxes, 4
checks
= 24 blank text boxes, etc...).

Duane gave me this code:

Private Sub Report_Page()
Dim intNumLines As Integer
Dim intLineNumber As Integer
Dim intTopMargin As Integer
Dim ctl As Control
Dim intLineHeight As Integer
Dim intLineLeft As Integer
Dim intLineWidth As Integer
intNumLines = 26
intLineLeft = 720 '1/2 inch from left margin
intLineWidth = 1440 * 5 '5 inches
intTopMargin = Me.Section(3).Height
intLineHeight = Me.Section(0).Height
Me.FontSize = 14
For intLineNumber = 0 To intNumLines - 1
Me.CurrentX = intLineLeft
Me.CurrentY = intTopMargin + _
(intLineNumber * intLineHeight)
Me.Print intLineNumber + 1
Me.Line (intLineLeft, intTopMargin + _
(intLineNumber * intLineHeight)) _
-Step(intLineWidth, 0)
Next
End Sub

But it gives me an error when I use it.

Error title Microsoft Visual Basic

Run-time error '6':

Overflow.



Are you sure the detail section is not too tall to display
26 times on one page.

You should use Long instead of integer just in case a line
is drawn more than 11 inches from the top of the page.

--
Marsh
MVP [MS Access]



  #4  
Old August 3rd, 2007, 03:15 PM posted to microsoft.public.access.reports
Marshall Barton
external usenet poster
 
Posts: 5,361
Default Problem with code to draw lines for blank fields

I have no idea what you mean by "I put in rectangles but
even though they are of the same size as the field I cannot
get them to perfectly match up", but that probably was a
waste of time, so it doesn't matter.

I still think the overflow error is caused by using Integer
instead of Long. Otherwise, Duane's code looks good to me.

There is one refinement that may help in your case. Add a
text box (named txtDetails) to the report (or group) Header
section and set it's control source to the expression
=Count(*)
Then modify the code to only draw the required number of
rectangles:
intNumLines = 28 - Me.txtDetails
--
Marsh
MVP [MS Access]


Michael wrote:
It definitely has enough room because if there are more checks (up to 26)
they fit but when there's only 1 check it doesn't display the boxes I need.

I put in rectangles but even though they are of the same size as the field I
cannot get them to perfectly match up.

Michael wrote:
I need to be able to have 28 text boxes, rectangles, etc.... anything that
will make between 1 and 28 rectangles so that if I have less than 28
checks
there will still be 28 boxes (i.e. 2 checks = 26 blank text boxes, 4
checks
= 24 blank text boxes, etc...).

Duane gave me this code:

Private Sub Report_Page()
Dim intNumLines As Integer
Dim intLineNumber As Integer
Dim intTopMargin As Integer
Dim ctl As Control
Dim intLineHeight As Integer
Dim intLineLeft As Integer
Dim intLineWidth As Integer
intNumLines = 26
intLineLeft = 720 '1/2 inch from left margin
intLineWidth = 1440 * 5 '5 inches
intTopMargin = Me.Section(3).Height
intLineHeight = Me.Section(0).Height
Me.FontSize = 14
For intLineNumber = 0 To intNumLines - 1
Me.CurrentX = intLineLeft
Me.CurrentY = intTopMargin + _
(intLineNumber * intLineHeight)
Me.Print intLineNumber + 1
Me.Line (intLineLeft, intTopMargin + _
(intLineNumber * intLineHeight)) _
-Step(intLineWidth, 0)
Next
End Sub

But it gives me an error when I use it.

Error title Microsoft Visual Basic

Run-time error '6':

Overflow.


"Marshall Barton" wrote.
Are you sure the detail section is not too tall to display
26 times on one page.

You should use Long instead of integer just in case a line
is drawn more than 11 inches from the top of the page.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:05 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.