Kath Pelletti
SDSSoftware at optusnet.com.au
Fri Nov 21 06:52:56 CST 2003
Hi Pedro - I had a very similar situation last year. My client was using a page of labels with 2 columns, 10 labels per column. The code below prompts the user for a label no and they enter the no. of the label they want to use, ie. 1 for 10 would print in the first column, and 11-20 print in the second column. Then by adjusting the height of the report header (section1) you can push the data down to the right place. It's a while since I wrote this and it looks like I had to create 2 reports to cater for the second column - the second report has a left margin of 11 cms. The code does force you to open the report in design mode to adjust the report header height, so you would have to distrubute as an mdb, not mde. But it works really well. HTH: code below - watch the wrap. Kath -------------------------------------- Private Sub PrintLabel_Click() Dim strerrormsg As String On Error GoTo Err_Handler Dim IntLabelNo As Integer, strMsg As String, Rptname As String Dim IntRptheight As Integer If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord End If Rptname = "RptClientLabel" 'Each cm is 567 twips in measurement strMsg = "Enter label no (from 1 to 10 for first column, and 10 to 20 for second column):" IntLabelNo = InputBox(Prompt:=strMsg, _ Title:="Client Labels", XPos:=2000, YPos:=2000) If IsNull(IntLabelNo) Or IntLabelNo = 0 Then MsgBox ("No label no selected"), vbOKOnly, "Reports" GoTo Normal_exit End If If IntLabelNo < 1 Or IntLabelNo > 20 Then MsgBox ("Label number can be from 1 to 20"), vbOKOnly, "Reports" GoTo Normal_exit End If If IntLabelNo > 10 Then Rptname = "RptClientLabelColumn2" 'push data to 2nd column IntLabelNo = IntLabelNo - 10 '11 become position 1, 12 becomes pos 2 etc. End If If IntLabelNo = 1 Then IntRptheight = 800 ElseIf IntLabelNo > 1 Then IntRptheight = ((IntLabelNo * 567) * 2.54) - 567 End If Application.Echo False If Rptname = "RptClientLabelColumn2" Then DoCmd.OpenReport "RptClientLabelColumn2", acViewDesign DoCmd.SelectObject acReport, "RptClientLabelColumn2" Reports!RptClientLabelColumn2.Section(1).Height = IntRptheight DoCmd.Save acReport, "RptClientLabelColumn2" DoCmd.close Application.Echo True DoCmd.OpenReport "RptClientLabelColumn2", acViewPreview, [ClientID] = Me.ClientID Else DoCmd.OpenReport "RptClientLabel", acViewDesign DoCmd.SelectObject acReport, "RptClientLabel" Reports!RptClientLabel.Section(1).Height = IntRptheight DoCmd.Save acReport, "RptClientLabel" DoCmd.close Application.Echo True DoCmd.OpenReport "Rptclientlabel", acViewPreview, [ClientID] = Me.ClientID End If Normal_exit: Application.Echo True DoCmd.SetWarnings True Exit Sub Err_Handler: Select Case Err.Number Case 13 Resume Normal_exit Case Else MsgBox "Error: [" & Err.Number & "] " & IIf(Len(strerrormsg) > 0, strerrormsg, Err.Description), vbCritical, "Error Message" Resume Normal_exit End Select End Sub ----- Original Message ----- From: pedro at plex.nl To: AccessD at databaseadvisors.com Sent: Friday, November 21, 2003 10:05 AM Subject: [AccessD] Hello group, i want to make adress-labels for 1 single adress. In our hospital we use sheets of labels. Is there a way on a form when i have selected one user, to give the position on the report, where the adress on the label must be printed. for example i have a labelsheet with 6 labels. Can i make command buttons an click on the third commandbutton, so that the adress is placed on the position of label3 "labelsheet" cmd1 cmd2 cmd3 cmd4 cmd5 cmd6 TIA Pedro Janssen _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com