PROCEDURE TOO LARGE - ERRO

SMZTODOPODEROSO 07/05/2012 16:28:53
#401503
O código que eu tenho é o seguinte
[quote]
Sub relatoriocantina1()
Dim nomeescola As String
nomeescola = GetSetting(AppName:=[Ô]Samuelteste[Ô], Section:=[Ô]escola[Ô], _
Key:=[Ô]Nome[Ô], Default:=[Ô]Falta preencher o nome da escola[Ô])
Dim hhora As String
Dim hdata As String
Dim hespaco As String
Dim htexto As String
Dim datahoraactual As String
hespaco = [Ô] - [Ô]
hhora = Format(Time, [Ô]HH:MM[Ô])
hdata = Format(Date, [Ô]YYYY-MM-DD[Ô])
htexto = [Ô]Visualizado em : [Ô]
datahoraactual = htexto + hdata + hespaco + hhora
Dim dblElapsed As Double
dblElapsed = Timer
frmcantina.lblEnd.Caption = [Ô][Ô]
Dim clPDF As New clsPDFCreator
Dim strFile As String
Dim i As Single
[ô] ************* Vai guardar o pdf
strFile = App.Path & [Ô]elatorio.pdf[Ô]
With clPDF
.Title = [Ô]DigiSiS - Relátorios[Ô] [ô] Titulo
.ScaleMode = pdfCentimeter [ô] Unità di misura
.PaperSize = pdfA4 [ô] Formato pagina
.Margin = 0 [ô] Margine
.Orientation = pdfPortrait [ô] Orientamento
.EncodeASCII85 = (frmcantina.chkASCII85.Value = Checked)
.InitPDFFile strFile [ô] inizializza il file
.LoadFont [Ô]Fnt1[Ô], [Ô]Times New Roman[Ô] [ô] Tipo TrueType
.LoadFont [Ô]Fnt2[Ô], [Ô]Arial[Ô], pdfItalic [ô] Tipo TrueType
.LoadFont [Ô]Fnt3[Ô], [Ô]Courier New[Ô] [ô] Tipo TrueType
.LoadFontStandard [Ô]Fnt4[Ô], [Ô]Courier New[Ô], pdfBoldItalic [ô] Tipo Type1
[ô] Definisce le risorse relative alle immagini
.LoadImgFromBMPFile [Ô]Img1[Ô], App.Path & [Ô]\img\20x20x24.bmp[Ô] [ô], pdfGrayScale
.LoadImgFromBMPFile [Ô]Img2[Ô], App.Path & [Ô]\img\200x200x24.bmp[Ô] [ô], pdfGrayScale
[ô] Definisce una risorsa comune da stampare solo sulle pagine pari
.StartObject [Ô]Item1[Ô], pdfAllPages [ô] , pdfEvenPages
.SetColorFill -240
.SetTextHorizontalScaling 120
.DrawText 6, 2, [Ô]DigiSiS[Ô], [Ô]Fnt2[Ô], 190, , 60
.SetColorFill 0
.EndObject
[ô] ******************************* inicio da pagina do pdf
.BeginPage
.DrawText 18.5, 1.5, [Ô]Página [Ô] & Trim(CStr(.Pages)), [Ô]Fnt1[Ô], 12, pdfAlignRight
.DrawObject [Ô]Footers[Ô]
.DrawText 10.5, 28, nomeescola, [Ô]Fnt1[Ô], 28, pdfCenter
.DrawText 20, 27, datahoraactual, [Ô]Fnt1[Ô], 12, pdfAlignRight
Dim cabecalho As String
Dim cabecalho2 As String
Dim cabecalho3 As String
Dim cabecalho4 As String
Dim prere1 As String
Dim prere2 As String
cabecalho = [Ô]Relatório - Movimentos da Cantina[Ô]
If frmcantina.Option7.Value = True Then
cabecalho2 = frmcantina.Option7.Caption
End If
If frmcantina.Option8.Value = True Then
cabecalho2 = frmcantina.Option8.Caption
End If
If frmcantina.Option9.Value = True Then
cabecalho2 = frmcantina.Option9.Caption
End If
cabecalho3 = [Ô]Refeitorio: [Ô]
cabecalho4 = cabecalho3 + cabecalho2
.DrawText 1, 27, cabecalho, [Ô]Fnt1[Ô], 18, pdfAlignLeft
.SetTextHorizontalScaling 70
.DrawText 20, 26, cabecalho4, [Ô]Fnt1[Ô], 16, pdfAlignRight
.DrawText 20, 25.4, [Ô]Almoço[Ô], [Ô]Fnt1[Ô], 16, pdfAlignRight
prere1 = [Ô]Relatório do dia : [Ô]
prere2 = Format(frmcantina.txtdata.Text, [Ô]YYYY-MM-dd[Ô])
cabecalho3 = prere1 + prere2
.DrawText 1, 26, cabecalho3, [Ô]Fnt1[Ô], 16, pdfAlignLeft
Dim valor As Long
Dim nrcantina As Integer
Dim tiporefeicao As Integer
Dim euros As Double
Dim texto As String
Dim nacantina As Long
Dim noexterior As Long
Dim nototal As Long
Dim nacantina1 As Double
Dim noexterior1 As Double
Dim nototal1 As Double
xabase = GetSetting(AppName:=[Ô]Samuelteste[Ô], Section:=[Ô]endereco[Ô], _
Key:=[Ô]Nome[Ô], Default:=[Ô]-----[Ô])
Set cnn = CreateObject([Ô]ADODB.Connection[Ô])
.DrawText 5, 24.7, [Ô]Cantina[Ô], [Ô]Fnt1[Ô], 16, pdfAlignLeft
.DrawText 7.5, 24.7, [Ô]Exterior[Ô], [Ô]Fnt1[Ô], 16, pdfAlignLeft
.DrawText 10, 24.7, [Ô]Total[Ô], [Ô]Fnt1[Ô], 16, pdfAlignLeft
.DrawText 13, 24.7, [Ô]Cantina[Ô], [Ô]Fnt1[Ô], 16, pdfAlignLeft
.DrawText 15.5, 24.7, [Ô]Exterior[Ô], [Ô]Fnt1[Ô], 16, pdfAlignLeft
.DrawText 18, 24.7, [Ô]Total[Ô], [Ô]Fnt1[Ô], 16, pdfAlignLeft
cnn.Open [Ô]DRIVER={MySQL ODBC 3.51 Driver};SERVER =[Ô] + xabase + [Ô];DATABASE=escola;UID=eli;PWD=eli123;OPTION=16427[Ô]
Set rs = CreateObject([Ô]ADODB.RecordSet[Ô])
Set rs.ActiveConnection = cnn
If frmcantina.Option7.Value = True Then
nrcantina = [Ô]1[Ô]
End If
If frmcantina.Option8.Value = True Then
nrcantina = [Ô]2[Ô]
End If
If frmcantina.Option9.Value = True Then
nrcantina = [Ô]3[Ô]
End If
tiporefeicao = [Ô]1[Ô]
i = 24
stropen = [Ô]SELECT count(idalmoco) as valor FROM 'almoco' where nrcantina =[ô][Ô] + Str$(nrcantina) + [Ô][ô] and tiporefeicao =[ô][Ô] + Str$(tiporefeicao) + [Ô][ô] and data =[ô][Ô] + prere2 + [Ô][ô] and localizacao =[ô]0[ô][Ô]
rs.Open stropen, cnn
If rs.EOF Or rs.BOF Then
valor = 0
rs.Close
Else
If IsNumeric(rs(0)) = False Then
valor = 0
Else
valor = rs.Fields([Ô]valor[Ô])
End If
rs.Close
End If
texto = valor
nacantina = valor
.DrawText 1, i, [Ô]Refeições marcadas:[Ô], [Ô]Fnt1[Ô], 16, pdfAlignLeft
.DrawText 5, i, texto, [Ô]Fnt1[Ô], 16, pdfAlignLeft
stropen = [Ô]SELECT count(idalmoco) as valor FROM 'almoco' where nrcantina =[ô][Ô] + Str$(nrcantina) + [Ô][ô] and tiporefeicao =[ô][Ô] + Str$(tiporefeicao) + [Ô][ô] and data =[ô][Ô] + prere2 + [Ô][ô] and localizacao =[ô]1[ô][Ô]
rs.Open stropen, cnn
If rs.EOF Or rs.BOF Then
valor = 0
rs.Close
Else
If IsNumeric(rs(0)) = False Then
valor = 0
Else
valor = rs.Fields([Ô]valor[Ô])
End If
rs.Close
End If
texto = valor
noexterior = valor
.DrawText 7.5, i, texto, [Ô]Fnt1[Ô], 16, pdfAlignLeft
nototal = nacantina + noexterior
texto = nototal
nacantina = 0
noexterior = 0
.DrawText 10, i, texto, [Ô]Fnt1[Ô], 16, pdfAlignLeft
stropen = [Ô]SELECT sum(preco+precomulta) as valor FROM 'almoco' where nrcantina =[ô][Ô] + Str$(nrcantina) + [Ô][ô] and tiporefeicao =[ô][Ô] + Str$(tiporefeicao) + [Ô][ô] and data =[ô][Ô] + prere2 + [Ô][ô] and localizacao=[ô]0[ô][Ô]
rs.Open stropen, cnn
If rs.EOF Or rs.BOF Then
euros = 0
rs.Close
Else
If IsNumeric(rs(0)) = False Then
euros = 0
Else
euros = rs.Fields([Ô]valor[Ô])
End If
rs.Close
End If
texto = Format(euros, [Ô]0.00[Ô])
texto = texto + [Ô] €[Ô]
nacantina1 = Format(euros, [Ô]0.00[Ô])
.DrawText 12, i, [Ô]Total:[Ô], [Ô]Fnt1[Ô], 16, pdfAlignLeft
.DrawText 13, i, texto, [Ô]Fnt1[Ô], 16, pdfAlignLeft
stropen = [Ô]SELECT sum(preco+precomulta) as valor FROM 'almoco' where nrcantina =[ô][Ô] + Str$(nrcantina) + [Ô][ô] and tiporefeicao =[ô][Ô] + Str$(tiporefeicao) + [Ô][ô] and data =[ô][Ô] + prere2 + [Ô][ô] and localizacao=[ô]1[ô][Ô]
rs.Open stropen, cnn
If rs.EOF Or rs.BOF Then
euros = 0
rs.Close
Else
If IsNumeric(rs(0)) = False Then
euros = 0
Else
euros = rs.Fields([Ô]valor[Ô])
End If
rs.Close
End If
texto = Format(euros, [Ô]0.00[Ô])
texto = texto + [Ô] €[Ô]
noexterior = Format(euros, [Ô]0.00[Ô])
.DrawText 15.5, i, texto, [Ô]Fnt1[Ô], 16, pdfAlignLeft
nototal1 = nacantina1 + noexterior1
texto = nototal1
texto = texto + [Ô] €[Ô]
nacantina = 0
noexterior = 0
.DrawText 18, i, texto, [Ô]Fnt1[Ô], 16, pdfAlignLeft
i = i - 1

stropen = [Ô]SELECT count(idalmoco) as valor FROM 'almoco' where nrcantina =[ô][Ô] + Str$(nrcantina) + [Ô][ô] and tiporefeicao =[ô][Ô] + Str$(tiporefeicao) + [Ô][ô] and data =[ô][Ô] + prere2 + [Ô][ô] and multa=[ô]0[ô] and localizacao =[ô]0[ô][Ô]
rs.Open stropen, cnn
If rs.EOF Or rs.BOF Then
valor = 0
rs.Close
Else
If IsNumeric(rs(0)) = False Then
valor = 0
Else
valor = rs.Fields([Ô]valor[Ô])
End If
rs.Close
End If
texto = valor
nacantina = valor
.DrawText 1, i, [Ô]Refeições sem multa:[Ô], [Ô]Fnt1[Ô], 16, pdfAlignLeft
.DrawText 5, i, texto, [Ô]Fnt1[Ô], 16, pdfAlignLeft
stropen = [Ô]SELECT count(idalmoco) as valor FROM 'almoco' where nrcantina =[ô][Ô] + Str$(nrcantina) + [Ô][ô] and tiporefeicao =[ô][Ô] + Str$(tiporefeicao) + [Ô][ô] and data =[ô][Ô] + prere2 + [Ô][ô] and multa=[ô]0[ô] and localizacao =[ô]1[ô][Ô]
rs.Open stropen, cnn
If rs.EOF Or rs.BOF Then
valor = 0
rs.Close
Else
If IsNumeric(rs(0)) = False Then
valor = 0
Else
valor = rs.Fields([Ô]valor[Ô])
End If
rs.Close
End If
texto = valor
noexterior = valor
.DrawText 7.5, i, texto, [Ô]Fnt1[Ô], 16, pdfAlignLeft
nototal = nacantina + noexterior
texto = nototal
nacantina = 0
noexterior = 0
.DrawText 10, i, texto, [Ô]Fnt1[Ô], 16, pdfAlignLeft
stropen = [Ô]SELECT sum(preco+precomulta) as valor FROM 'almoco' where nrcantina =[ô][Ô] + Str$(nrcantina) + [Ô][ô] and tiporefeicao =[ô][Ô] + Str$(tiporefeicao) + [Ô][ô] and data =[ô][Ô] + prere2 + [Ô][ô] and multa=[ô]0[ô] and localizacao=[ô]0[ô][Ô]
rs.Open stropen, cnn
If rs.EOF Or rs.BOF Then
euros = 0
rs.Close
Else
If IsNumeric(rs(0)) = False Then
euros = 0
Else
euros = rs.Fields([Ô]valor[Ô])
End If
rs.Close
End If
texto = Format(euros, [Ô]0.00[Ô])
texto = texto + [Ô] €[Ô]
nacantina1 = Format(euros, [Ô]0.00[Ô])
.DrawText 12, i, [Ô]Total:[Ô], [Ô]Fnt1[Ô], 16, pdfAlignLeft
.DrawText 13, i, texto, [Ô]Fnt1[Ô], 16, pdfAlignLeft
stropen = [Ô]SELECT sum(preco+precomulta) as valor FROM 'almoco' where nrcantina =[ô][Ô] + Str$(nrcantina) + [Ô][ô] and tiporefeicao =[ô][Ô] + Str$(tiporefeicao) + [Ô][ô] and data =[ô][Ô] + prere2 + [Ô][ô] and multa=[ô]0[ô] and localizacao=[ô]1[ô][Ô]
rs.Open stropen, cnn
If rs.EOF Or rs.BOF Then
euros = 0
rs.Close
Else
If IsNumeric(rs(0)) = False
SMZTODOPODEROSO 07/05/2012 16:31:04
#401504
?o erro deve de ser por ter excesso de linhas num ciclo?
JCARLOS 08/05/2012 08:11:16
#401518
é meu caro, vc terá de quebrar a sua rotina criandou sub-rotinas. Existe um limite dentro de uma rotina.
Abraços.
Tópico encerrado , respostas não são mais permitidas