Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nextrecord, printsection properties of a report

Status
Not open for further replies.

ITA

Programmer
Nov 9, 1999
18
0
0
US
Hi,<br>&nbsp;&nbsp;&nbsp;&nbsp;I am using the following code to print one record as many times as the value entered in the listbox. It will work if the value is 1, however when you enter any other number in the list box multiple labels are printed. I was wondering if anyone else has any suggestions.<br><br>CODE.......<br><br>Dim intSkipped As Integer<br>Dim intToSkip As Integer<br>Dim LabelCopies&<br>Dim CopyCount&<br><br><br>Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)<br>&nbsp;&nbsp;&nbsp;'This set of code tell access to not advance to the next record and print the same record again<br>&nbsp;&nbsp;&nbsp;If intSkipped &lt; intToSkip Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me.NextRecord = False<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me.PrintSection = False<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;intSkipped = intSkipped + 1<br>&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;CopyCount& = 0<br>&nbsp;&nbsp;&nbsp;If CopyCount& &lt; (LabelCopies& - 1) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me.NextRecord = False<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CopyCount& = CopyCount& + 1<br>&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CopyCount& = 0<br>&nbsp;&nbsp;&nbsp;End If<br>End Sub<br><br>Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)<br>&nbsp;&nbsp;&nbsp;'This code is where the skip label position and number of labels to print is generated from<br>&nbsp;&nbsp;&nbsp;intSkipped = 0<br>&nbsp;&nbsp;&nbsp;intToSkip = adhGetLabelsToSkip(FormName:=&quot;frmSelectLabel&quot;, _<br>&nbsp;&nbsp;&nbsp;&nbsp;Rows:=7, Cols:=2, Start:=1, PrintAcross:=True)<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;LabelCopies& = Val(inputbox$(&quot;Enter Number of Copies to Print&quot;))<br>&nbsp;&nbsp;&nbsp;If LabelCopies& &lt; 1 Then LabelCopies& = 1<br>End Sub
 
Not sure where you got &quot;Me.NextRecord&quot;<br>I wish it would work. <br>.MoveNext is the correct parameter but it does not work with the Form like Me.MoveNext either.<br>The only way I know of is set the forms recordset to <br>Me.RecordsetClone which takes a copy of the forms records and puts them in something which you manipulate and then pass back to the form using a Bookmark.<br><br>So let me see, you want to print the number of labels based on a selected item in a list box right?<br>So if the List box number is 4 then you want to print 4 copies of the same labels???<br>And what else?<br><br>Also this function is missing from your paste:<br>adhGetLabelsToSkip(FormName:=&quot;frmSelectLabel&quot;, _<br>&nbsp;&nbsp;&nbsp;&nbsp;Rows:=7, Cols:=2, Start:=1, PrintAcross:=True)<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;<br><br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Doug,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The nextrecord and printsection reference can be found in the access help file. I will enclude the excert from the help file for everyone to look at and use.<br><br>***********************************************************<br>You can use combinations of these property settings in Visual Basic to specify or change a report's layout when the report is previewed, printed, or saved to a file:<br><br>· The MoveLayout property specifies whether Microsoft Access should move to the next printing location on the page.<br>· The NextRecord property specifies whether a section should advance to the next record.<br>· The PrintSection property specifies whether a section should be printed.<br><br>Setting<br><br>The MoveLayout property uses the following settings.<br><br>Setting Description<br>True (–1) (Default) The section's Left and Top properties are advanced to the next print location.<br>False (0) The section's Left and Top properties are unchanged.<br>The NextRecord property uses the following settings.<br><br>Setting Description<br>True (Default) The section advances to the next record.<br>False The section doesn't advance to the next record.<br>The PrintSection property uses the following settings.<br><br>Setting Description<br>True (Default) The section is printed.<br>&nbsp;False The section isn't printed.<br>To set these properties, specify a macro or event procedure for a section's OnFormat property.<br>Microsoft Access sets these properties to True before each section's Format event.<br><br>Remarks<br><br>These properties are useful when you want to use a report as a template into which you write data from a macro or Visual Basic as you print.<br>The following table shows the result of different setting combinations for these properties.<br><br>MoveLayout NextRecord PrintSection Description<br>True True True (Default) Move to the next print location, get the next record, and print the data.<br>True False True Move to the next print location, don't advance to the next record, but print the data. This combination is typically used when the data in a section requires more space than the layout allows and you want to print the remaining data in the space that would otherwise be occupied by the next section.<br>False True False Skip a record without leaving a blank space on the page.<br>True True False Skip a record and leave a blank space on the page.<br>True False False Leave a blank space without skipping a record.<br>False True True Print the current record on top of the last record as an overlay.<br>False False True Not allowed.<br>False False False Not allowed.<br><br>************************************************************<br><br>Here is the code for that function....<br><br>***********************************************************<br>Function adhGetLabelsToSkip(FormName As String, Rows As Integer, _<br>&nbsp;Cols As Integer, Start As Integer, PrintAcross As Boolean) As Integer<br>&nbsp;&nbsp;&nbsp;&nbsp;On Error GoTo adhGetLabelsToSkip_Err<br><br>&nbsp;&nbsp;&nbsp;&nbsp;' Pop up a form, requesting the starting label.<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;' In:<br>&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;&nbsp;&nbsp;&nbsp;FormName: string containing the name of the form to open<br>&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;&nbsp;&nbsp;&nbsp;Rows: Number of rows to display on the form<br>&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;&nbsp;&nbsp;&nbsp;Cols: Number of cols to display on the form<br>&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;&nbsp;&nbsp;&nbsp;Start: Which label to select, by default<br>&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;&nbsp;&nbsp;&nbsp;PrintAcross: True to number across first,<br>&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;False to number down first.<br>&nbsp;&nbsp;&nbsp;&nbsp;' Out:<br>&nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;&nbsp;&nbsp;&nbsp;Return value: the number of the starting label<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;' First, open the label-choosing form.<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenForm FormName:=FormName, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WindowMode:=acDialog, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OpenArgs:=
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top