Predmet:Re: Problem Petlja
ovo je rijesenje
Public Function taxaOddo()
Dim rst As DAO.Recordset
IzborPrintera
br = 1
izn = 0
siznos = 0
Suma = 0
kizlaz = 0
Close #1
Set rst = CurrentDb.OpenRecordset("KORISNIK")
'Open rst!Port For Output As #1
Open "C:\Temp\taxa.txt" For Output As #1
Print #1, strParPrint
Print #1, strIzbTrake
Print #1, strObSlova
Print #1, Tab(21 - Len(rst!korisnik)); rst!korisnik
Print #1, Tab(21 - Len(rst!adresa) - Len(rst!grad)); Nz(rst!adresa, ""); ","; Nz(rst!grad)
Print #1, "Izvjestaj o prodatim artiklima za period"
Print #1, Tab(7); "od"; Tab(10); Format(pocetni, "dd.mm.yyyy"); Tab(22); "do"; Tab(25); Format(krajnji, "dd.mm.yyyy")
Print #1, "========================================"
Print #1, " Datum Taxa Iznos"
Print #1, "========================================"
rst.Close
Set rst = CurrentDb.OpenRecordset("select * from Qzaperiod1 WHERE datum BETWEEN DATEVALUE('" & pocetni & "') AND DATEVALUE('" & krajnji & "')")
rst.MoveFirst
Datum = rst!Datum
Do Until rst.EOF
sif = rst!proizvod
im = rst!ime
izn = rst!SumOfiznos
If Datum <> rst!Datum Then
Print #1, "----------------------------------------"
Print #1, Datum; Tab(41 - Len(Format(siznos, "###0.00"))); Format(siznos, "###0.00")
Print #1, "----------------------------------------"
Suma = Suma + rst!SumOfiznos
siznos = 0
Datum = rst!Datum
End If
Print #1, Format(rst!Datum, "dd.mm.yyyy"); " "; sif; Tab(16); right(im, 24); Tab(41 - Len(Format(izn, "###0.00"))); Format(izn, "###0.00")
siznos = siznos + rst!SumOfiznos
rst.MoveNext
Loop
Print #1, "----------------------------------------"
rst.MoveFirst
Suma = Suma + rst!SumOfiznos
If Datum <> rst!Datum Then
Print #1, Datum; Tab(41 - Len(Format(siznos, "###0.00"))); Format(siznos, "###0.00")
Print #1, "----------------------------------------"
End If
'****************
rst.MoveFirst
Suma = 0
Datum = rst!Datum
Do Until rst.EOF
Suma = Suma + rst!SumOfiznos
rst.MoveNext
Loop
rst.MoveFirst
Print #1, "SVEUKUPNO : "; Tab(41 - Len(Format(Suma, "###0.00"))); Format(Suma, "###0.00")
Print #1, "----------------------------------------"
Print #1, Chr(27) & Chr(100) & Chr(8)
Print #1, Chr(27) & Chr(105)
Close #1
End Function
hvala svima za pomoc
nevsad ramic