vanis
10-05-2010 18:27:08
Tomas como farei para carregar os dados de uma planilha usando os comandos pelo module.
seria mais ou menos o seu exemplo de modelo de cadastro feito todo dentro do module.
o formulario so ia puxar os comandos, eu fiz aqui as modificações mais não consegui passar o registros clicando nos botoes,
minha maior dificuldade e que quando programamos dentro do module e que modifica um pouco os comandos.
se vc tiver algum exenplo posta ele ai pra mim. obrigado
segue os codigos de carregar como exemplo( as variaveis indiceRegistro e indiceMinimo sao globais)
Sub CarregaRegistro()
Dim ultimo_reg As Long
Dim posicao As String
Dim j As Integer
Dim i As Integer
Dim g As Integer
Dim minimo As Integer
ActiveWorkbook.Worksheets("Projeto").Select
Range("x1").Select
ActiveCell.FormulaR1C1 = "=COUNTA(C[-23])"
ultimo_reg = Range("x1").Value
minimo = ultimo_reg - 2
j = 1
i = 1
For i = minimo To ultimo_reg - 1
'frmCadastro.txtResponsavel.Text = IndiceResgistro colResponsavel.Value
frmCadastro.txtCodigoFornecedor.Text = Sheets("Projeto").Range("A" & j)
frmCadastro.txtResponsavel.Text = Sheets("Projeto").Range("B" & j)
frmCadastro.txtDatadoProjeto.Text = Sheets("Projeto").Range("C" & j)
frmCadastro.txtNomedoLab.Text = Sheets("Projeto").Range("D" & j)
frmCadastro.cboTipoProjeto.Text = Sheets("Projeto").Range("E" & j)
frmCadastro.txtNomeProjeto.Text = Sheets("Projeto").Range("F" & j)
frmCadastro.txtIdProjeto.Text = Sheets("Projeto").Range("G" & j)
frmCadastro.txtTotalProjeto.Text = Sheets("Projeto").Range("H" & j)
frmCadastro.cboRevisao.Text = Sheets("Projeto").Range("I" & j)
frmCadastro.cboRemanejamento.Text = Sheets("Projeto").Range("J" & j)
frmCadastro.txtRecebe.Text = Sheets("Projeto").Range("K" & j)
frmCadastro.txtCedendo.Text = Sheets("Projeto").Range("L" & j)
frmCadastro.txtOBS.Text = Sheets("Projeto").Range("N" & j)
j = j + 1
Next i
end sub
Sub VoltaRegistro()
ActiveWorkbook.Worksheets("Projeto").Select
Range("x1").Select
ActiveCell.FormulaR1C1 = "=COUNTA(C[-23])"
indiceRegistro = Range("x1").Value
If indiceRegistro > indiceMinimo Then
indiceRegistro = indiceMinimo - 1
Call CarregaRegistro
End If
' If indiceRegistro > 1 Then
'Call CarregaRegistro
' End If
End Sub
seria mais ou menos o seu exemplo de modelo de cadastro feito todo dentro do module.
o formulario so ia puxar os comandos, eu fiz aqui as modificações mais não consegui passar o registros clicando nos botoes,
minha maior dificuldade e que quando programamos dentro do module e que modifica um pouco os comandos.
se vc tiver algum exenplo posta ele ai pra mim. obrigado
segue os codigos de carregar como exemplo( as variaveis indiceRegistro e indiceMinimo sao globais)
Sub CarregaRegistro()
Dim ultimo_reg As Long
Dim posicao As String
Dim j As Integer
Dim i As Integer
Dim g As Integer
Dim minimo As Integer
ActiveWorkbook.Worksheets("Projeto").Select
Range("x1").Select
ActiveCell.FormulaR1C1 = "=COUNTA(C[-23])"
ultimo_reg = Range("x1").Value
minimo = ultimo_reg - 2
j = 1
i = 1
For i = minimo To ultimo_reg - 1
'frmCadastro.txtResponsavel.Text = IndiceResgistro colResponsavel.Value
frmCadastro.txtCodigoFornecedor.Text = Sheets("Projeto").Range("A" & j)
frmCadastro.txtResponsavel.Text = Sheets("Projeto").Range("B" & j)
frmCadastro.txtDatadoProjeto.Text = Sheets("Projeto").Range("C" & j)
frmCadastro.txtNomedoLab.Text = Sheets("Projeto").Range("D" & j)
frmCadastro.cboTipoProjeto.Text = Sheets("Projeto").Range("E" & j)
frmCadastro.txtNomeProjeto.Text = Sheets("Projeto").Range("F" & j)
frmCadastro.txtIdProjeto.Text = Sheets("Projeto").Range("G" & j)
frmCadastro.txtTotalProjeto.Text = Sheets("Projeto").Range("H" & j)
frmCadastro.cboRevisao.Text = Sheets("Projeto").Range("I" & j)
frmCadastro.cboRemanejamento.Text = Sheets("Projeto").Range("J" & j)
frmCadastro.txtRecebe.Text = Sheets("Projeto").Range("K" & j)
frmCadastro.txtCedendo.Text = Sheets("Projeto").Range("L" & j)
frmCadastro.txtOBS.Text = Sheets("Projeto").Range("N" & j)
j = j + 1
Next i
end sub
Sub VoltaRegistro()
ActiveWorkbook.Worksheets("Projeto").Select
Range("x1").Select
ActiveCell.FormulaR1C1 = "=COUNTA(C[-23])"
indiceRegistro = Range("x1").Value
If indiceRegistro > indiceMinimo Then
indiceRegistro = indiceMinimo - 1
Call CarregaRegistro
End If
' If indiceRegistro > 1 Then
'Call CarregaRegistro
' End If
End Sub