Buongiorno. In pratica la parte che ho indicato sotto ( DA DOVE È COMMENTATO INIZIO PARTE INTERESSATA), la inserisce in ogni pagina ma vorrei la inserisse solo nell'ultima
Public Function Data()
Dim NrecPieni As Integer
Dim NrecTot As Integer
Dim n, k As Integer
Dim Nca, Nca1 As Integer
Dim sqlr, sqlrp As String
Dim MyRSR, MyRSP As Result
Dim Pqua, Pimp, Ptot, Psco As String
Dim Fpaga, Fbanc, Fiban, IdPag, Mtex As String
Dim Nfat, Fa1, Fa2 As String
Dim MT As String
Dim $Impor As String
Dim r As Integer
Dim iDecimali As Integer
Nfat = fatture.TextArea1.text
If Nfat Then
nca = InStr(Nfat, "\n")
If nca > 0 Then
Fa1 = Mid(Nfat, 1, nca - 1)
Fa2 = Mid(Nfat, nca)
Else
If Len(Nfat) > 62 Then
Fa1 = Mid(Nfat, 1, InStr(Nfat, " ", 58))
Fa2 = Mid(Nfat, Len(Fa1) + 1)
Else
Fa1 = Nfat
Endif
Endif
Endif
nca = 0
idpag = Fatture.TextBox6.text
sqlrp = "SELECT * FROM pagamenti WHERE pagamento LIKE '%" & idpag & "'"
MyRSP = MODMain.MyConn.Exec(sqlrp)
If MyRSp.Available Then
fpaga = MyRSP!pagamento
If Fpaga And InStr(Fpaga, "(") Then Fpaga = Mid(Fpaga, 1, InStr(Fpaga, "(") - 1)
Mtex = MyRSP!testo
If UCase(fpaga) = "OMAGGIO" Then
If Mtex Then
nca = InStr(Mtex, "\n")
If nca > 0 Then
Fpaga = Fpaga & " - " & Mid(mtex, 1, nca - 1)
nca1 = InStr(Mtex, "\n", nca + 1)
Fbanc = Mid(mtex, nca, nca1 - nca)
Fiban = Mid(mtex, nca1)
Else
If Len(mtex) > 62 Then
Fpaga = Fpaga & " - " & Mid(mtex, 1, InStr(mtex, " ", 46))
fbanc = Mid(mtex, (Len(fpaga) - 11), InStr(mtex, " ", 104) - (Len(fpaga) - 11))
Fiban = Mid(mtex, Len(fbanc) + (Len(fpaga) - 10))
Else
Fbanc = mtex
Endif
Endif
Endif
Else
If Mtex Then
nca = InStr(Mtex, "\n")
If nca > 0 Then
Fbanc = Mid(mtex, 1, nca - 1)
Fiban = Mid(mtex, nca)
Else
If Len(mtex) > 62 Then
fbanc = Mid(mtex, 1, InStr(mtex, " ", 58))
Fiban = Mid(mtex, Len(fbanc) + 1)
Else
Fbanc = mtex
Endif
Endif
Endif
Endif
Endif
nca = 0
sqlr = "SELECT * FROM riffatture WHERE idfatture = '" & fatture.IdRec & "'"
MyRSR = MODMain.MyConn.Exec(sqlr)
If MyRSr.Available Then
NrecPieni = MyRSR.Count
MyRSR.MoveFirst
If NrecPieni < 21 Then
NrecTot = 20
maxp = 1
Else If NrecPieni < 54 Then '
NrecTot = 53
maxp = 2
Else If NrecPieni < 87 Then
NrecTot = 86
maxp = 3
Else If NrecPieni < 120 Then
NrecTot = 119
maxp = 4
Else If NrecPieni < 153 Then
NrecTot = 152
maxp = 5
Else If NrecPieni < 186 Then
NrecTot = 185
maxp = 6
Else If NrecPieni < 219 Then
NrecTot = 218
maxp = 7
Else If NrecPieni < 252 Then
NrecTot = 251
maxp = 8
Else If NrecPieni < 285 Then
NrecTot = 284
maxp = 9
Else If NrecPieni < 318 Then
NrecTot = 317
maxp = 10
Else If NrecPieni < 351 Then
NrecTot = 350
maxp = 11
Else If NrecPieni < 384 Then
NrecTot = 383
maxp = 12
Else If NrecPieni < 417 Then
NrecTot = 416
maxp = 13
Else
Message.Error("raggiunto il numero massimo di pagine consentite")
End If
Me.AddPage()
Me.Bookmark("Page 1")
Me.SetXY(10, 70)
Me.Ln()
Me.SetFont("Arial", "", 10)
Me.SetFillColor(245, 245, 245)
'inizo parte database ----------------------------------
For n = 1 To NrecPieni
If MyRSR!quantita > 0 Then
Pqua = Format(MyRSR!quantita, "#####0")
Else
Pqua = Null
Endif
If MyRSR!prezzo > 0 Then
$Impor = CFloat(MyRSR!prezzo)
r = InStr($Impor, ".")
iDecimali = Len($Impor) - r
If iDecimali < 2 Or r = 0 Then iDecimali = 2
Select iDecimali
Case 2
Pimp = Format(MyRSR!prezzo, "#####0.00")
Case 3
Pimp = Format(MyRSR!prezzo, "#####0.000")
Case 4
Pimp = Format(MyRSR!prezzo, "#####0.0000")
Case 5
Pimp = Format(MyRSR!prezzo, "#####0.00000")
Case 6
Pimp = Format(MyRSR!prezzo, "#####0.000000")
End Select
Else
pimp = Null
Endif
If MyRSR!sconto > 0 Then
Psco = Format(MyRSR!sconto, "#####0.00")
Else
Psco = Null
Endif
If MyRSR!subtotale > 0 Then
Ptot = Format(MyRSR!subtotale, "#####0.00")
Else
Ptot = Null
Endif
Me.Cell(30, 6, MyRSR!codice, False, 0, "C", False)
Me.Cell(13, 6, Pqua, False, 0, "C", False)
Me.Cell(95, 6, MyRSR!descrizione, False, 0, "L", False)
Me.Cell(17, 6, Pimp, False, 0, "C", False)
Me.Cell(15, 6, Psco, False, 0, "C", False)
Me.SetFillColor(245, 245, 245)
Me.Cell(20, 6, Ptot, True, 0, "C", True)
MyRSR.MoveNext
Me.Ln()
Next
If fatture.TextBox5.Text Then ccor = "Consegna: " & UCase(fatture.TextBox5.Text)
'fine parte database ----------------------------------
If NrecTot > NrecPieni Then
For k = NrecPieni To NrecTot - 1
Me.Cell(33, 6,, False, 0, "L", False)
Me.Ln()
Next
Endif
' INIZIO PARTE INTERESSATA
Me.Ln() '8
Me.Cell(120, 22, "", True, 0, "", False)
Me.Ln(-3)
Me.SetX(20)
Me.SetFillColor(255, 255, 255)
Me.SetFont("Arial", "I", 11)
Me.Cell(45, 6, "Modalita' di Pagamento", False, 0, "C", True)
Me.SetFont("Arial", "", 10)
Me.Ln()
Me.SetX(12)
Me.Cell(116, 6, fpaga, False, 0, "L", False)
Me.Ln(-4)
Me.SetX(126)
Me.Cell(15, 6, "", False, 0, "L", False) 'spinta
Me.Cell(27, 6, "Imponibile ", False, 0, "R", False)
Me.Cell(32, 6, fatture.textbox10.text & " ", True, 0, "R", False)
Me.Ln(10)
Me.SetX(12)
Me.Cell(116, 6, Fbanc, False, 0, "L", False)
Me.Ln()
Me.SetX(12)
Me.Cell(116, 6, Fiban, False, 0, "L", False)
Me.Ln(-9)
Me.SetX(126)
Me.Cell(15, 6, "", False, 0, "L", False) 'spinta
Me.Cell(27, 6, "Tasso Iva % ", False, 0, "R", False)
Me.Cell(32, 6, fatture.textbox3.text & " ", True, 0, "C", False)
Me.Ln(21)
Me.Cell(120, 22, "", True, 0, "", False)
Me.Ln(-3)
Me.SetX(22)
Me.SetFillColor(255, 255, 255)
Me.SetFont("Arial", "I", 11)
Me.Cell(45, 6, "Indirizzo di Spedizione", False, 0, "C", True)
Me.Ln(-11)
Me.SetX(141)
Me.SetFont("Arial", "", 10)
Me.Cell(27, 6, "Imposta ", False, 0, "R", False)
Me.Cell(32, 6, fatture.textbox4.text & " ", True, 0, "R", False)
Me.Ln(17)
Me.SetX(12)
Me.Cell(116, 6, Indsp1, False, 0, "L", False)
Me.Ln(-10)
Me.SetX(141)
Me.SetFont("Arial", "", 11)
Me.Cell(27, 6, "Spese Sped. ", False, 0, "R", False)
Me.Cell(32, 6, fatture.textbox2.text & " ", True, 0, "R", False)
Me.Ln(15)
Me.SetX(12)
Me.Cell(116, 6, Indsp2, False, 0, "L", False)
Me.Ln()
Me.SetX(12)
Me.Cell(116, 6, Ccor, False, 0, "L", False)
Me.Ln(-14)
Me.SetX(141)
Me.Cell(27, 6, "Sconto/Coupon ", False, 0, "R", False)
Me.Cell(32, 6, fatture.textbox8.text & " ", True, 0, "R", False)
Me.Ln(7)
Me.SetX(141)
Me.Cell(27, 6, "Acconto ", False, 0, "R", False)
Me.Cell(32, 6, fatture.textbox9.text & " ", True, 0, "R", False)
Me.Ln(10)
Me.SetX(141)
mt = "Totale € " '& Chr(128)
Me.SetFont("Arial", "B", 11)
Me.Cell(27, 6, mt, False, 0, "R", False)
Me.Cell(32, 6, fatture.textbox7.text & " ", True, 0, "R", False)
Me.Line(10, 256, 20, 256)
Me.Line(45, 256, 130, 256)
Me.Line(10, 256, 10, 272)
Me.Line(130, 256, 130, 272)
Me.Line(10, 272, 130, 272)
Me.Ln(10)
Me.Cell(120, 16, "", False, 0, "", False)
Me.Ln(-3)
Me.SetX(20)
Me.SetFillColor(255, 255, 255)
Me.SetFont("Arial", "I", 11)
Me.Cell(25, 6, "Annotazioni", False, 0, "C", False)
Me.Ln(-3)
Me.Cell(130, 6, "", False, 0, "L", False) 'spinta
Me.SetFont("Arial", "", 9)
Me.Cell(27, 6, "(S.E.& O.) ", False, 0, "R", False)
Me.SetFont("Arial", "", 11)
Me.Ln()
Me.Ln(2)
Me.SetX(12)
Me.Cell(116, 6, fa1, False, 0, "L", False)
Me.Ln()
Me.SetX(12)
Me.Cell(116, 6, fa2, False, 0, "L", False)
Me.SetFillColor(0, 0, 0)
Me.SetFont("Arial", "I", 5)
Me.Code39(135, 260, fatture.TextBNum.text, False, False, 0.4, 8, False)
Endif
end