Ir para conteúdo
Fórum Script Brasil
  • 0

Erro de compilação (PROCEDURE TOO LARGE)Como divido uma PRIVATE SUB?


Marcelo Cavalcanti

Pergunta

:rolleyes: [i.m.g]http://img196.imageshack.us/img196/381/telah.jpg[/i.m.g]

[i.m.g]http://yfrog.com/5gtelahj[/i.m.g]

Private Sub cmdImprimirCaP_Click() 'Verifica o poder para a impressão

If Poder <= 1 Then

Principal.Report.WindowShowPrintBtn = False

Principal.Report.WindowShowExportBtn = False

Else

Principal.Report.WindowShowPrintBtn = True

Principal.Report.WindowShowExportBtn = True

End If

caminho = App.Path + "\dados\XYZ.mdb"

Principal.Report.DataFiles(0) = caminho

'**R E L A T Ó R I O S COM 1(UM)F O R N E C E D O R S E L E C I O N A D O**

If chkGroupFornec.Value = vbChecked Then

'1 - CONTAS A PAGAR POR VENCIMENTO, COM FORNECEDOR SELECIONADO.

'OK

'0 - Contas a Pagar com Fornecedor Selecionado

'0 - Vencimento

'0 - Não Baixadas

'0 - Total

If CmbFornec.Text <> "" _

And OptCaP(0).Value = True _

And OptVencPag(0).Value = True _

And OptBaixa(0).Value = True _

And Optstatuscap(0).Value = True Then

Principal.Report.ReportFileName = App.Path & "\Rel\Contas_pag_Fornec.rpt"

Principal.Report.WindowTitle = "Listagem de Contas a Pagar. Agrupado por Fornecedor"

Principal.Report.SelectionFormula = "{Forpag.vencimen} >= #" + Format(Txt_DtInic, "mm/dd/yyyy") + "# and {Forpag.vencimen} <= #" + Format(Txt_DtFin, "mm/dd/yyyy") + "# AND {fornec.nome}='" & CmbFornec & "' AND ISNULL({FORPAG.DATAPG}) AND ({FORPAG.BAIXA}) = 'N'" ' NÃO PAGAS

Principal.Report.Formulas(0) = "filtro = '" & filtro & "'"

Principal.Report.Formulas(1) = "licenciado = '" & licenciadox & "'"

Principal.Report.Formulas(2) = "titulo = '" & "Contas a Pagar por Fornecedor no período de " & Txt_DtInic & " até " & Txt_DtFin & "'"

Principal.Report.Formulas(3) = "ordem = '" & "Classificado por Vencimento" & "'"

Principal.Report.Formulas(4) = "positivo = '" & "Total" & "'"

Principal.Report.Destination = 0

Principal.Report.Action = 1

'OK

'0 - Contas a Pagar com Fornecedor Selecionado

'0 - Vencimento

'0 - Não Baixadas

'1 - Positivo

ElseIf CmbFornec.Text <> "" _

And OptCaP(0).Value = True _

And OptVencPag(0).Value = True _

And OptBaixa(0).Value = True _

And Optstatuscap(1).Value = True Then

Principal.Report.ReportFileName = App.Path & "\Rel\Contas_pag_Fornec.rpt"

Principal.Report.WindowTitle = "Listagem de Contas a Pagar. Agrupado por Fornecedor"

Principal.Report.SelectionFormula = "{Forpag.vencimen} >= #" + Format(Txt_DtInic, "mm/dd/yyyy") + "# and {Forpag.vencimen} <= #" + Format(Txt_DtFin, "mm/dd/yyyy") + "# AND {fornec.nome}='" & CmbFornec & "' AND ({FORPAG.BAIXA}) = 'N' AND ({FORPAG.NFISCAL}) >= 0 AND ISNULL({FORPAG.DATAPG})" 'Contas A PAGAR por data de VENCIMENTO."

Principal.Report.Formulas(0) = "filtro = '" & filtro & "'"

Principal.Report.Formulas(1) = "licenciado = '" & licenciadox & "'"

Principal.Report.Formulas(2) = "titulo = '" & "Contas a Pagar por Fornecedor no período de " & Txt_DtInic & " até " & Txt_DtFin & "'"

Principal.Report.Formulas(3) = "ordem = '" & "Classificado por Vencimento" & "'"

Principal.Report.Formulas(4) = "positivo = '" & "Positivo" & "'"

Principal.Report.Destination = 0

Principal.Report.Action = 1

'OK

'0 - Contas a Pagar com Fornecedor Selecionado

'0 - Vencimento

'0 - Não Baixadas

'2 - Negativo

( O procedimento acima acontece mais 42 vezes, ate o end if e else para continuar novamente)

End If

Else

'********I N I C I O DO CONTAS A PAGAR POR PERÍODO**********

''1.0 - CONTAS A PAGAR POR VENCIMENTO, NÃO BAIXADAS.

'OK

'0 - Contas a Pagar

'0 - Vencimento

'0 - Não Baixadas

'0 - Total

If OptCaP(0).Value = True And OptVencPag(0).Value = True And OptBaixa(0).Value = True And Optstatuscap(0).Value = True Then

Principal.Report.ReportFileName = App.Path & "\Rel\Contas_Pag_Ordem_Venc.rpt"

Principal.Report.WindowTitle = "Listagem de Contas a Pagar ordenado por vencimento"

Principal.Report.SelectionFormula = "{Forpag.vencimen} >= #" + Format(Txt_DtInic, "mm/dd/yyyy") + "# and {Forpag.vencimen} <= #" + Format(Txt_DtFin, "mm/dd/yyyy") + "# AND ISNULL({FORPAG.DATAPG}) AND ({FORPAG.BAIXA}) = 'N' " 'Contas A PAGAR por data de VENCIMENTO."

Principal.Report.Formulas(0) = "filtro = '" & filtro & "'"

Principal.Report.Formulas(1) = "licenciado = '" & licenciadox & "'"

Principal.Report.Formulas(2) = "titulo = '" & "Contas a Pagar no período de " & Txt_DtInic & " até " & Txt_DtFin & "'"

Principal.Report.Formulas(3) = "ordem = '" & "Classificado por Vencimento" & "'"

Principal.Report.Formulas(4) = "positivo = '" & "Total" & "'"

Principal.Report.Destination = 0

Principal.Report.Action = 1

'OK

'0 - Contas a Pagar

'0 - Vencimento

'0 - Não Baixadas

'1 - Positivo

ElseIf OptCaP(0).Value = True And OptVencPag(0).Value = True And OptBaixa(0).Value = True And Optstatuscap(1).Value = True Then

Principal.Report.ReportFileName = App.Path & "\Rel\Contas_Pag_Ordem_Venc.rpt"

Principal.Report.WindowTitle = "Listagem de Contas a Pagar ordenado por vencimento"

Principal.Report.SelectionFormula = "{Forpag.vencimen} >= #" + Format(Txt_DtInic, "mm/dd/yyyy") + "# and {Forpag.vencimen} <= #" + Format(Txt_DtFin, "mm/dd/yyyy") + "# AND ({FORPAG.BAIXA}) = 'N' AND ({FORPAG.NFISCAL}) >= 0 AND ISNULL({FORPAG.DATAPG})" 'Contas A PAGAR por data de VENCIMENTO."

Principal.Report.Formulas(0) = "filtro = '" & filtro & "'"

Principal.Report.Formulas(1) = "licenciado = '" & licenciadox & "'"

Principal.Report.Formulas(2) = "titulo = '" & "Contas a Pagar no período de " & Txt_DtInic & " até " & Txt_DtFin & "'"

Principal.Report.Formulas(3) = "ordem = '" & "Classificado por Vencimento" & "'"

Principal.Report.Formulas(4) = "positivo = '" & "Positivo" & "'"

Principal.Report.Destination = 0

Principal.Report.Action = 1

( O procedimento acima acontece mais 49 vezes, ate o fim abaixo.)

'OK

'2 - Todas

'0 - Nota Fiscal

'0 - Negativo

ElseIf OptCaP(2).Value = True And OptVencPag(2).Value = True And Optstatuscap(2).Value = True Then

Principal.Report.ReportFileName = App.Path & "\Rel\Contas_Pag_NFiscal.rpt"

Principal.Report.WindowTitle = "Listagem de Contas Pagas Ordenado por Nota Fiscal"

Principal.Report.SelectionFormula = "{Forpag.Emissao} >= #" + Format(Txt_DtInic, "mm/dd/yyyy") + "# and {Forpag.Emissao} <= #" + Format(Txt_DtFin, "mm/dd/yyyy") + "# AND ({FORPAG.NFISCAL}) <=0"

Principal.Report.Formulas(0) = "filtro = '" & filtro & "'"

Principal.Report.Formulas(1) = "licenciado = '" & licenciadox & "'"

Principal.Report.Formulas(2) = "titulo = '" & "Contas Pagas e a Pagar no período de " & Txt_DtInic & " até " & Txt_DtFin & "'"

Principal.Report.Formulas(3) = "ordem = '" & "Classificado por Nota Fiscal" & "'"

Principal.Report.Formulas(4) = "positivo = '" & "Negativo" & "'"

Principal.Report.Destination = 0

Principal.Report.Action = 1

End If

For I = 1 To 23

Principal.Report.Formulas(1) = ""

Next

End If

End Sub

Editado por Marcelo Cavalcanti
Link para o comentário
Compartilhar em outros sites

4 respostass a esta questão

Posts Recomendados

  • 0
Boa tarde a todos.

Na hora que eu vou rodar o programa, quando eu acrescento mais alguns (IF)s

da pau e fala que o procedimento é muito longo(PROCEDURE TOO LARGE).

Existe alguma soluçao para o erro?

COMO DIVIDO A SUB?

Agradeço antecipadamente a atenção de todos.

Marcelo Cavalcanti

posta a sub aew pra gente da uma olhda

abraço

t+

Link para o comentário
Compartilhar em outros sites

  • 0

marcelo, isso acontece mesmo, no visual basic uma funcao não pode passar de um numero certo de linhas.

e acho q o mesmo server pra cada formulario ou module, depois de um limite ele não compila mais.

você vai ter q separar a sua sub em varias, e, se for preciso, vai ter q separar em varios modules tb.

mas seila, se o procedimento acontece 49 vezes, não é melhor por dentro dum for em vez de escrever o codigo todo 49 vezes??

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652k
×
×
  • Criar Novo...