4章 カスタマイズ /4-4レポート品名単位に印刷する[Access97] |
| <設定手順> |
apRptFormat Me
行は、コメントにします。
Private Sub 詳細_Format(Cancel As Integer, FormatCount As Integer)
' apRptFormat Me
'品名単位の印刷
If Me![品名1] = "" Or IsNull(Me![品名1]) Then
'ページ内にスペースを残さずにレコードをスキップします。
Me.MoveLayout = False
Me.NextRecord = True
Me.PrintSection = False
Exit Sub
End If
'印刷枚数確定
Dim lngMax As Long '印刷商品数
lngMax = 1
If Me![品名1] <> "" And Not (IsNull(Me![品名1])) Then
lngMax = 1
End If
If Me![品名2] <> "" And Not (IsNull(Me![品名2])) Then
lngMax = 2
End If
If Me![品名3] <> "" And Not (IsNull(Me![品名3])) Then
lngMax = 3
End If
If Me![品名4] <> "" And Not (IsNull(Me![品名4])) Then
lngMax = 4
End If
If Me![品名5] <> "" And Not (IsNull(Me![品名5])) Then
lngMax = 5
End If
If IsNull(Me![TextCount]) Then
Me![TextCount] = 1 'カウント初期化
End If
If Me![TextCount] <> lngMax Then
'次の印字位置に進み,同一レコードを印刷する。
If Err = 0 Then
Me.MoveLayout = True
Me.NextRecord = False
Me.PrintSection = True
End If
End If
End Sub
apRptPrint Me
行は、コメントにします。
Private Sub 詳細_Print(Cancel As Integer, PrintCount As Integer)
' apRptPrint Me
'品名単位の印刷
'印刷枚数確定
Dim lngMax As Long '印刷商品数
lngMax = 1
If Me![品名1] <> "" And Not (IsNull(Me![品名1])) Then
lngMax = 1
End If
If Me![品名2] <> "" And Not (IsNull(Me![品名2])) Then
lngMax = 2
End If
If Me![品名3] <> "" And Not (IsNull(Me![品名3])) Then
lngMax = 3
End If
If Me![品名4] <> "" And Not (IsNull(Me![品名4])) Then
lngMax = 4
End If
If Me![品名5] <> "" And Not (IsNull(Me![品名5])) Then
lngMax = 5
End If
'内容設定
Select Case Me![TextCount]
Case 1
Me![商品番号] = Me![商品番号1]
Me![品名] = Me![品名1]
Case 2
Me![商品番号] = Me![商品番号2]
Me![品名] = Me![品名2]
Case 3
Me![商品番号] = Me![商品番号3]
Me![品名] = Me![品名3]
Case 4
Me![商品番号] = Me![商品番号4]
Me![品名] = Me![品名4]
Case 5
Me![商品番号] = Me![商品番号5]
Me![品名] = Me![品名5]
End Select
'カウント設定
If Me![TextCount] <> lngMax Then
Me![TextCount] = Me![TextCount] + 1
Else
Me![TextCount] = 1
End If
End Sub