Vídeo recomendado
https://youtu.be/diWPPPhW-9E
https://youtu.be/diWPPPhW-9E
Modelo cadastro atendimentos
-
- Colaborador
- Mensagens: 15
- Registrado em: Seg Nov 03, 2014 5:17 pm
Modelo cadastro atendimentos
boa noite
estou desenvolvendo um cadastro de atendimento de equipamentos de ar condicionado. Estou desenvolvendo a partir do modelo de vcs, em um único arquivo, so que para um único registro (id pedido) posso ter atendimento a mais de um equipamento, os equipamentos atendidos estão dispostos em listview, o que gera números iguais de registro em linhas diferentes. (mesmo numero de registro em linhas diferentes). Isso acaba bagunçando o carregamento por índice.
Teria alguma forma de fazer estes registros? alguém ja adaptou para algo parecido? uso salvamento em duas planilhas? salvando os dados da listview em outra aba? qual seria a solução mais simples?
obrigada
estou desenvolvendo um cadastro de atendimento de equipamentos de ar condicionado. Estou desenvolvendo a partir do modelo de vcs, em um único arquivo, so que para um único registro (id pedido) posso ter atendimento a mais de um equipamento, os equipamentos atendidos estão dispostos em listview, o que gera números iguais de registro em linhas diferentes. (mesmo numero de registro em linhas diferentes). Isso acaba bagunçando o carregamento por índice.
Teria alguma forma de fazer estes registros? alguém ja adaptou para algo parecido? uso salvamento em duas planilhas? salvando os dados da listview em outra aba? qual seria a solução mais simples?
obrigada
Re: Modelo cadastro atendimentos
Alessandra,
Utilize três planilhas, uma para Clientes, uma para os Equipamentos pertencentes á cada cliente e a última para consolidar e controlar os atendimentos.
O ideal é utilizar dois campos ID em seu banco de dados de atendimento. O primeiro sempre para ID de registro e o segundo associado ao ID do cliente.
Abs
Utilize três planilhas, uma para Clientes, uma para os Equipamentos pertencentes á cada cliente e a última para consolidar e controlar os atendimentos.
O ideal é utilizar dois campos ID em seu banco de dados de atendimento. O primeiro sempre para ID de registro e o segundo associado ao ID do cliente.
Abs
-
- Colaborador
- Mensagens: 15
- Registrado em: Seg Nov 03, 2014 5:17 pm
Re: Modelo cadastro atendimentos
fiz como sugerido mas está dando erro no salvamento do registro.
poderiam ver o que fiz de errado?
como faço para compartilhar o arquivo?
Obrigda
poderiam ver o que fiz de errado?
como faço para compartilhar o arquivo?
Obrigda
-
- Colaborador
- Mensagens: 15
- Registrado em: Seg Nov 03, 2014 5:17 pm
Re: Modelo cadastro atendimentos
boa noite, acho que consegui.. segue arquivo.
se puderem ajudar, agradeço imensamente.
se puderem ajudar, agradeço imensamente.
- Anexos
-
- 05. Controle_Geral - site.rar
- (290.86 KiB) Baixado 432 vezes
-
- Colaborador
- Mensagens: 15
- Registrado em: Seg Nov 03, 2014 5:17 pm
Re: Modelo cadastro atendimentos
Alterei o comando salvaregistro, ainda assim tá dando erro conforme abaixo destacado amarelo.
Preciso que ao salvar na plan09, se não tiver o registro que busque a próxima linha vaga, e se encontrar , altere ou inclua informações .. portanto tem que procurar, mas o erro ocorre na linha WHILE.
Alguma luz?
Private Sub SalvaRegistro(ByVal id As Long, ByVal indice As Long)
'Início da Sub:
Application.ScreenUpdating = False
Dim i As Integer
Dim Resp
'* Faz os testes para certificar que os campos estão preenchidos
'** teste para verificar o preenchimento do cliente
If txt_id = "" Then
MsgBox "Preencha endereço", vbOKOnly + vbExclamation, Soft
Me.MultiPage1.Value = 0
txt_endereco.SetFocus
Exit Sub
End If
Resp = MsgBox("Deseja realmente SALVAR?", vbYesNo + vbDefaultButton1, Soft)
If Resp = vbNo Then
Resp = MsgBox("Deseja CANCELAR?", vbYesNo + vbDefaultButton2, Soft)
If Resp = vbYes Then
MsgBox "Ação cancelada pelo usuário!", vbInformation, Soft
Exit Sub
End If
End If
'*** Laço para lançar todos os itens do pedido na planilha
Plan07.Activate
On Error Resume Next
'* Dados da aba cliente * Declaração das variáveis
Dim id_pedido As Long
Dim id_cliente As Integer
Dim data_pedido As Date
id_pedido = txtitens_cadastrados
id_cliente = txt_id
data_pedido = Now()
Cells(indice, COLIDSOL) = id_pedido 'ID do pedido
Cells(indice, COLDATAPEDIDO) = Format(data_pedido, dMask) ' data
Cells(indice, COLSol) = cmb_tipo
Cells(indice, COLTIPO) = txt_compl
Cells(indice, COLIDEndereco) = id_cliente ' Id do Código do cliente
Cells(indice, COLEndereco) = txt_endereco
Cells(indice, COLTIPOIMOVEL) = txt_tipoimovel
Cells(indice, COLCIDADE) = txt_cidade
Cells(indice, COLREGIONAL) = txt_regional
Cells(indice, COLITEM) = txt_item
Cells(indice, COLCONTATO) = txt_contato
Cells(indice, COLTELEFONE) = txt_telefone
Cells(indice, COLEMAIL) = txt_email
Cells(indice, COLENG) = txt_eng
Cells(indice, COLOFICIO) = txt_oficio
Cells(indice, COLPROTOCOLO) = txt_protocolo
If chb_orc = True Then
Cells(indice, COLORC) = "True"
Else
Cells(indice, COLORC) = "False"
End If
If chb_aprov = True Then
Cells(indice, COLAPROV) = "True"
Else
Cells(indice, COLAPROV) = "False"
End If
If chb_exec = True Then
Cells(indice, COLEXEC) = "True"
Else
Cells(indice, COLEXEC) = "False"
End If
Cells(indice, COLCORR) = txt_correcao
Cells(indice, COLDATASOLORC) = Format(txt_so, dMask)
Cells(indice, COLORDEMEXEC) = Format(txt_oe, dMask)
Cells(indice, COLCONCLUSAO) = Format(txt_conclusao, dMask)
Cells(indice, COLVALOR) = CDbl(txt_valor)
Cells(indice, COLEMPRESA) = cmb_empresa
Cells(indice, COLEMPENHO) = txt_empenho
Cells(indice, COLPROCESSO) = txt_processo
Cells(indice, COLDATAACEITE) = Format(txt_aceite, dMask)
Cells(indice, COLNF) = txt_notafiscal
Cells(indice, COLGARANTIA) = Format(txt_garantia, dMask)
Cells(indice, COLCONSIDERACOES) = txt_obs
Cells(indice, COLSTATUS) = cmb_status
Plan09.Activate
Dim linha
'* Dados do pedido * Declaração das variáveis
Dim aparelho '*se o código tiver letras usar string
Dim btu
Dim sala
Dim area
Dim idpedido
Dim qtdedisp
Dim qtdepessoas
Dim te
Dim infra
Dim comp
Dim impress
Dim fax
Dim outros
Dim reprog
Dim btusnec
Dim qtddisp
Dim autoenvio
Dim patrimonio
Dim m2
Dim coluna
Dim valor_celula
If list_pedidos.ListItems.Count = 0 Then
Exit Sub
Else
For i = 1 To list_pedidos.ListItems.Count
'** Atribuindo valores as variáveis com os dados da listview
idpedido = list_pedidos.ListItems.Item(i)
qtdedisp = list_pedidos.ListItems.Item(i).SubItems(1)
aparelho = list_pedidos.ListItems.Item(i).SubItems(2)
btu = list_pedidos.ListItems.Item(i).SubItems(3)
sala = list_pedidos.ListItems.Item(i).SubItems(5)
m2 = list_pedidos.ListItems.Item(i).SubItems(6)
qtdepessoas = list_pedidos.ListItems.Item(i).SubItems(7)
te = list_pedidos.ListItems.Item(i).SubItems(8)
infra = list_pedidos.ListItems.Item(i).SubItems(9)
comp = list_pedidos.ListItems.Item(i).SubItems(10)
impress = list_pedidos.ListItems.Item(i).SubItems(11)
fax = list_pedidos.ListItems.Item(i).SubItems(12)
reprog = list_pedidos.ListItems.Item(i).SubItems(13)
outros = list_pedidos.ListItems.Item(i).SubItems(14)
btusnec = list_pedidos.ListItems.Item(i).SubItems(15)
autoenvio = list_pedidos.ListItems.Item(i).SubItems(16)
coluna = 2
While Plan09.Cells(linha, coluna).Value <> Empty
valor_celula = Plan09.Cells(linha, coluna).Value
If InStr(1, UCase(valor_celula), UCase(txtitens_cadastrados)) > 0 Then
'Lançando os dados na planilha
Plan09.Cells(linha, 1) = Me.txtitens_cadastrados
Plan09.Cells(linha, 3) = Format(txt_datapedido, dMask)
Plan09.Cells(linha, 4) = cmb_tipo
Plan09.Cells(linha, 5) = txt_compl
Plan09.Cells(linha, 6) = txt_id
Plan09.Cells(linha, 7) = txt_endereco
Plan09.Cells(linha, 8) = txt_tipoimovel
Plan09.Cells(linha, 9) = txt_cidade
Plan09.Cells(linha, 10) = txt_regional
Plan09.Cells(linha, 11) = txt_item
Plan09.Cells(linha, 12) = cmb_status
Plan09.Cells(linha, 13) = m2
Plan09.Cells(linha, 14) = qtdepessoas
Plan09.Cells(linha, 15) = te
Plan09.Cells(linha, 16) = infra
Plan09.Cells(linha, 17) = comp
Plan09.Cells(linha, 18) = impress
Plan09.Cells(linha, 19) = fax
Plan09.Cells(linha, 20) = reprog
Plan09.Cells(linha, 21) = outros
Plan09.Cells(linha, 22) = btusnec
Plan09.Cells(linha, 22) = qtdedisp
Plan09.Cells(linha, 24) = btu
Plan09.Cells(linha, 25) = aparelho
Plan09.Cells(linha, 26) = patrimonio
Plan09.Cells(linha, 27) = sala
Plan09.Cells(linha, 29) = autoenvio
Else
linha = Plan09.UsedRange.Rows.Count + 1
Plan09.Cells(linha, 1) = Me.txtitens_cadastrados
Plan09.Cells(linha, 3) = Format(txt_datapedido, dMask)
Plan09.Cells(linha, 4) = cmb_tipo
Plan09.Cells(linha, 5) = txt_compl
Plan09.Cells(linha, 6) = txt_id
Plan09.Cells(linha, 7) = txt_endereco
Plan09.Cells(linha, 8) = txt_tipoimovel
Plan09.Cells(linha, 9) = txt_cidade
Plan09.Cells(linha, 10) = txt_regional
Plan09.Cells(linha, 11) = txt_item
Plan09.Cells(linha, 12) = cmb_status
Plan09.Cells(linha, 13) = m2
Plan09.Cells(linha, 14) = qtdepessoas
Plan09.Cells(linha, 15) = te
Plan09.Cells(linha, 16) = infra
Plan09.Cells(linha, 17) = comp
Plan09.Cells(linha, 18) = impress
Plan09.Cells(linha, 19) = fax
Plan09.Cells(linha, 20) = reprog
Plan09.Cells(linha, 21) = outros
Plan09.Cells(linha, 22) = btusnec
Plan09.Cells(linha, 22) = qtdedisp
Plan09.Cells(linha, 24) = btu
Plan09.Cells(linha, 25) = aparelho
Plan09.Cells(linha, 26) = patrimonio
Plan09.Cells(linha, 27) = sala
Plan09.Cells(linha, 29) = autoenvio
End If
linha = linha + 1
Wend
Next i
End If
'Salva Plan e seleciona para geração de recibo de pedido
ActiveWorkbook.Save
Call AtualizaRegistroCorrente
'Fim da Sub
Application.ScreenUpdating = True
End Sub
Preciso que ao salvar na plan09, se não tiver o registro que busque a próxima linha vaga, e se encontrar , altere ou inclua informações .. portanto tem que procurar, mas o erro ocorre na linha WHILE.
Alguma luz?
Private Sub SalvaRegistro(ByVal id As Long, ByVal indice As Long)
'Início da Sub:
Application.ScreenUpdating = False
Dim i As Integer
Dim Resp
'* Faz os testes para certificar que os campos estão preenchidos
'** teste para verificar o preenchimento do cliente
If txt_id = "" Then
MsgBox "Preencha endereço", vbOKOnly + vbExclamation, Soft
Me.MultiPage1.Value = 0
txt_endereco.SetFocus
Exit Sub
End If
Resp = MsgBox("Deseja realmente SALVAR?", vbYesNo + vbDefaultButton1, Soft)
If Resp = vbNo Then
Resp = MsgBox("Deseja CANCELAR?", vbYesNo + vbDefaultButton2, Soft)
If Resp = vbYes Then
MsgBox "Ação cancelada pelo usuário!", vbInformation, Soft
Exit Sub
End If
End If
'*** Laço para lançar todos os itens do pedido na planilha
Plan07.Activate
On Error Resume Next
'* Dados da aba cliente * Declaração das variáveis
Dim id_pedido As Long
Dim id_cliente As Integer
Dim data_pedido As Date
id_pedido = txtitens_cadastrados
id_cliente = txt_id
data_pedido = Now()
Cells(indice, COLIDSOL) = id_pedido 'ID do pedido
Cells(indice, COLDATAPEDIDO) = Format(data_pedido, dMask) ' data
Cells(indice, COLSol) = cmb_tipo
Cells(indice, COLTIPO) = txt_compl
Cells(indice, COLIDEndereco) = id_cliente ' Id do Código do cliente
Cells(indice, COLEndereco) = txt_endereco
Cells(indice, COLTIPOIMOVEL) = txt_tipoimovel
Cells(indice, COLCIDADE) = txt_cidade
Cells(indice, COLREGIONAL) = txt_regional
Cells(indice, COLITEM) = txt_item
Cells(indice, COLCONTATO) = txt_contato
Cells(indice, COLTELEFONE) = txt_telefone
Cells(indice, COLEMAIL) = txt_email
Cells(indice, COLENG) = txt_eng
Cells(indice, COLOFICIO) = txt_oficio
Cells(indice, COLPROTOCOLO) = txt_protocolo
If chb_orc = True Then
Cells(indice, COLORC) = "True"
Else
Cells(indice, COLORC) = "False"
End If
If chb_aprov = True Then
Cells(indice, COLAPROV) = "True"
Else
Cells(indice, COLAPROV) = "False"
End If
If chb_exec = True Then
Cells(indice, COLEXEC) = "True"
Else
Cells(indice, COLEXEC) = "False"
End If
Cells(indice, COLCORR) = txt_correcao
Cells(indice, COLDATASOLORC) = Format(txt_so, dMask)
Cells(indice, COLORDEMEXEC) = Format(txt_oe, dMask)
Cells(indice, COLCONCLUSAO) = Format(txt_conclusao, dMask)
Cells(indice, COLVALOR) = CDbl(txt_valor)
Cells(indice, COLEMPRESA) = cmb_empresa
Cells(indice, COLEMPENHO) = txt_empenho
Cells(indice, COLPROCESSO) = txt_processo
Cells(indice, COLDATAACEITE) = Format(txt_aceite, dMask)
Cells(indice, COLNF) = txt_notafiscal
Cells(indice, COLGARANTIA) = Format(txt_garantia, dMask)
Cells(indice, COLCONSIDERACOES) = txt_obs
Cells(indice, COLSTATUS) = cmb_status
Plan09.Activate
Dim linha
'* Dados do pedido * Declaração das variáveis
Dim aparelho '*se o código tiver letras usar string
Dim btu
Dim sala
Dim area
Dim idpedido
Dim qtdedisp
Dim qtdepessoas
Dim te
Dim infra
Dim comp
Dim impress
Dim fax
Dim outros
Dim reprog
Dim btusnec
Dim qtddisp
Dim autoenvio
Dim patrimonio
Dim m2
Dim coluna
Dim valor_celula
If list_pedidos.ListItems.Count = 0 Then
Exit Sub
Else
For i = 1 To list_pedidos.ListItems.Count
'** Atribuindo valores as variáveis com os dados da listview
idpedido = list_pedidos.ListItems.Item(i)
qtdedisp = list_pedidos.ListItems.Item(i).SubItems(1)
aparelho = list_pedidos.ListItems.Item(i).SubItems(2)
btu = list_pedidos.ListItems.Item(i).SubItems(3)
sala = list_pedidos.ListItems.Item(i).SubItems(5)
m2 = list_pedidos.ListItems.Item(i).SubItems(6)
qtdepessoas = list_pedidos.ListItems.Item(i).SubItems(7)
te = list_pedidos.ListItems.Item(i).SubItems(8)
infra = list_pedidos.ListItems.Item(i).SubItems(9)
comp = list_pedidos.ListItems.Item(i).SubItems(10)
impress = list_pedidos.ListItems.Item(i).SubItems(11)
fax = list_pedidos.ListItems.Item(i).SubItems(12)
reprog = list_pedidos.ListItems.Item(i).SubItems(13)
outros = list_pedidos.ListItems.Item(i).SubItems(14)
btusnec = list_pedidos.ListItems.Item(i).SubItems(15)
autoenvio = list_pedidos.ListItems.Item(i).SubItems(16)
coluna = 2
While Plan09.Cells(linha, coluna).Value <> Empty
valor_celula = Plan09.Cells(linha, coluna).Value
If InStr(1, UCase(valor_celula), UCase(txtitens_cadastrados)) > 0 Then
'Lançando os dados na planilha
Plan09.Cells(linha, 1) = Me.txtitens_cadastrados
Plan09.Cells(linha, 3) = Format(txt_datapedido, dMask)
Plan09.Cells(linha, 4) = cmb_tipo
Plan09.Cells(linha, 5) = txt_compl
Plan09.Cells(linha, 6) = txt_id
Plan09.Cells(linha, 7) = txt_endereco
Plan09.Cells(linha, 8) = txt_tipoimovel
Plan09.Cells(linha, 9) = txt_cidade
Plan09.Cells(linha, 10) = txt_regional
Plan09.Cells(linha, 11) = txt_item
Plan09.Cells(linha, 12) = cmb_status
Plan09.Cells(linha, 13) = m2
Plan09.Cells(linha, 14) = qtdepessoas
Plan09.Cells(linha, 15) = te
Plan09.Cells(linha, 16) = infra
Plan09.Cells(linha, 17) = comp
Plan09.Cells(linha, 18) = impress
Plan09.Cells(linha, 19) = fax
Plan09.Cells(linha, 20) = reprog
Plan09.Cells(linha, 21) = outros
Plan09.Cells(linha, 22) = btusnec
Plan09.Cells(linha, 22) = qtdedisp
Plan09.Cells(linha, 24) = btu
Plan09.Cells(linha, 25) = aparelho
Plan09.Cells(linha, 26) = patrimonio
Plan09.Cells(linha, 27) = sala
Plan09.Cells(linha, 29) = autoenvio
Else
linha = Plan09.UsedRange.Rows.Count + 1
Plan09.Cells(linha, 1) = Me.txtitens_cadastrados
Plan09.Cells(linha, 3) = Format(txt_datapedido, dMask)
Plan09.Cells(linha, 4) = cmb_tipo
Plan09.Cells(linha, 5) = txt_compl
Plan09.Cells(linha, 6) = txt_id
Plan09.Cells(linha, 7) = txt_endereco
Plan09.Cells(linha, 8) = txt_tipoimovel
Plan09.Cells(linha, 9) = txt_cidade
Plan09.Cells(linha, 10) = txt_regional
Plan09.Cells(linha, 11) = txt_item
Plan09.Cells(linha, 12) = cmb_status
Plan09.Cells(linha, 13) = m2
Plan09.Cells(linha, 14) = qtdepessoas
Plan09.Cells(linha, 15) = te
Plan09.Cells(linha, 16) = infra
Plan09.Cells(linha, 17) = comp
Plan09.Cells(linha, 18) = impress
Plan09.Cells(linha, 19) = fax
Plan09.Cells(linha, 20) = reprog
Plan09.Cells(linha, 21) = outros
Plan09.Cells(linha, 22) = btusnec
Plan09.Cells(linha, 22) = qtdedisp
Plan09.Cells(linha, 24) = btu
Plan09.Cells(linha, 25) = aparelho
Plan09.Cells(linha, 26) = patrimonio
Plan09.Cells(linha, 27) = sala
Plan09.Cells(linha, 29) = autoenvio
End If
linha = linha + 1
Wend
Next i
End If
'Salva Plan e seleciona para geração de recibo de pedido
ActiveWorkbook.Save
Call AtualizaRegistroCorrente
'Fim da Sub
Application.ScreenUpdating = True
End Sub