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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|