
tito13
Membros-
Total de itens
32 -
Registro em
-
Última visita
Tudo que tito13 postou
-
Estou usando o access 2003. Faço a coneçao na tela de splash Private Sub Tmr1_Timer() Dim x As Long With ProgressBar1 .Min = 0 .Max = 50000 .Value = 1 End With For x = 1 To 50000 ProgressBar1.Value = x Next On Error GoTo errConexão cnnCetecInfServiços.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & App.Path & "\CetecInfServiços.mdb;" cnnCetecInfServiços.Open Unload Me MDIFrm1.Show Exit Sub errConexão: With Err If .Number <> 0 Then MsgBox "Houve erro na conexão com o Banco de Dados." & _ vbCrLf & "O Sistema será encerrado.", vbCritical, vbOKOnly, "Erro de Conexão" .Number = 0 Set cnnCetecInfServiços = Nothing End End If End With End Sub
-
cara o pior é que vou la na tabela do access, incluo dados volto pra vb e lá tá o novo item. Vai entender??? Quatro dias e não consigo resolver. Se alguém mais puder dar uma dica, to aceitando.
-
Valeu Fabin Ta me retornando 'Method or data not foud' e me sinalizando no connectioString então tentei mudar para ActiveConnection e ai volta a me dizer que inclui mas não inclui. Vou revisar novamente. Se tiver outra ideia, agradeço. t+
-
se puderem, me digam onde estou errando, pois não ta gravando na tabela do access Private Sub IncluirDados() Dim vConfMsg As Integer Dim vErro As Boolean 'inicializa as variaveis auxiliares vConfMsg = vbExclamation + vbOKOnly + vbSystemModal vErro = False 'verifica os dados digitados If TxtNomeCliente.Text = Empty Then MsgBox "O campo Nome não foi preenchido.", vConfMsg, "Erro" vErro = True End If If TxtTel.Text = Empty Then MsgBox "O campo Telefone não foi preenchido.", vConfMsg, "Erro" vErro = True End If If TxtCidade.Text = Empty Then MsgBox "O campo Cidade não foi preenchido.", vConfMsg, "Erro" vErro = True End If If TxtDataInicioServico.Text = Empty Then MsgBox "O campo Data Entrada não foi preenchido.", vConfMsg, "Erro" vErro = True End If If TxtHoraInicioServico.Text = Empty Then MsgBox "O campo Hora Entrada não foi preenchido.", vConfMsg, "Erro" vErro = True End If If TxtProduto.Text = Empty Then MsgBox "O campo Produto não foi preenchido.", vConfMsg, "Erro" vErro = True End If If TxtMotivo.Text = Empty Then MsgBox "O campo Motivo da Chamada não foi preenchido.", vConfMsg, "Erro" vErro = True End If If TxtObs.Text = Empty Then MsgBox "O campo Observação não foi preenchido.", vConfMsg, "Erro" vErro = True End If 'Se acontece um erro sai da sub sem gravar If vInclusao = True Then With rsSelecao .AddNew !Nome = TxtNomeCliente.Text !Telefone = TxtTel.Text !Cidade = TxtCidade.Text !Data_Inicio_Servico = TxtDataInicioServico.Text !Hora_InicioServico = TxtHoraInicioServico.Text !Produto = TxtProduto.Text !Motivo_Chamada = TxtMotivo.Text !Obs = TxtObs.Text End With End If MsgBox "Inclusão ok", vbInformation + vbOKOnly + vbApplicationModal, "OK" LimparTela errGravacao: With Err If .Number <> 0 Then MsgBox "Houve erro na inclusão dos dados na tabela.", vbExclamation + vbOKOnly + vbApplicationModal, "Erro" .Number = 0 End If End With End Sub Informa que foi incluido mas não grava. fico no aguardo
-
então kuroi, obrigado pela paciencia mas veja agora, depois da arrumaçao, ficou assim: na general Dim rsSelecao As New ADODB.Recordset abro a recodset aqui Private Sub TxtCodCliente_LostFocus() Dim cnnComando As New ADODB.Command Dim rsSelecao As New ADODB.Recordset On Error GoTo errSelecao 'verifica se foi digitado codigo valido If Val(TxtCodCliente.Text) = 0 Then MsgBox "Não foi digitado um código válido, verifique.", vbExclamation + vbOKOnly + vbApplicationModal, "Erro" Exit Sub End If Screen.MousePointer = vbHourglass With cnnComando .ActiveConnection = Lider .CommandType = adCmdText 'monta o comando select para selecionar o registro na tabela. .CommandText = "SELECT * FROM Clientes WHERE Codigo_Cliente = " & TxtCodCliente.Text & ";" Set rsSelecao = .Execute End With With rsSelecao If .EOF And .BOF Then 'se recorset estiver vazio não retona registro com o codigo LimparDados 'identifica a operaçao como inclusao vInclusao = True Else 'senao atribui ao campo os dados do registro TxtNomeCliente.Text = !Nome TxtTel.Text = Empty & !Telefone TxtCidade.Text = !Cidade TxtDataInicioServico.Text = !Data_Inicio_Servico TxtHoraInicioServico.Text = !Hora_Inicio_Servico TxtProduto.Text = !Produto TxtMotivo.Text = !Motivo_Chamada TxtObs.Text = !Obs 'identifica a operacao como alteracao: vInclusao = False 'Habilita o botao excluir Toolbar1.Buttons(3).Enabled = True End If End With 'desabilita a digitacao do campo codigo TxtCodCliente.Enabled = False Saida: 'elimina o comand e o recorset da memoria: Set cnnComando = Nothing Screen.MousePointer = vbDefault Exit Sub errSelecao: With Err If .Number <> 0 Then MsgBox "Houve um erro na recuperacao do registro solicitado.", vbExclamation + vbOKOnly + vbApplicationModal, "Aviso" .Number = 0 GoTo Saida End If End With End Sub não fecho e abro as subs assim Private Sub ProximoRegistro() Dim cnnComando As New ADODB.Command With cnnComando .ActiveConnection = cnnlider .CommandType = adCmdText .CommandText = "Select * From Clientes WHERE Codigo_Cliente = " & TxtCodCliente.Text & ";" .Execute If rsSelecao.EOF <> True Then rsSelecao.MoveNext End If End With Mostrar End Sub Private Sub RegistroAnterior() Dim cnnComando As New ADODB.Command With cnnComando .ActiveConnection = cnnLider .CommandType = adCmdText .CommandText = "Select * From Clientes WHERE Codigo_Cliente = " & TxtCodCliente.Text & ";" .Execute If rsSelecao.BOF <> True Then rsSelecao.MovePrevious End If End With Mostrar End Sub e me retorna dizendo que o objeto não esta aberto????
-
Valeu Kuroi, mas infelizmente não resolveu. Fiz as alteraçoes sugiridas mas ele continua igual. Por exemplo: se eu me posiciono no terceiro lançamento e clico para ele ir para o proximo ele retorna para o primeiro lançamento da tabela e isso acontece tambem quando clico para ele ir para o anterior. Mesmo que as subs sejam diferentes ocorre a mesma coisa. Fiz as alteraçoes: Coloquei na General: Dim rsSelecao As New ADODB.Recordset e alterei: Private Sub ProximoRegistro() Dim cnnComando As New ADODB.Command With cnnComando .ActiveConnection = cnnCetecInfServiços .CommandType = adCmdText .CommandText = "Select * From Clientes WHERE Codigo_Cliente = " & TxtCodCliente.Text & ";" Set rsSelecao = .Execute If rsSelecao.EOF <> True Then rsSelecao.MoveNext End If End With Mostrar End Sub Private Sub RegistroAnterior() Dim cnnComando As New ADODB.Command With cnnComando .ActiveConnection = cnnCetecInfServiços .CommandType = adCmdText .CommandText = "Select * From Clientes WHERE Codigo_Cliente = " & TxtCodCliente.Text & ";" Set rsSelecao = .Execute If rsSelecao.BOF <> True Then rsSelecao.MovePrevious End If End With Mostrar End Sub Se puder me de mais alguma dica.
-
Não estou conseguindo encontrar o erro. Nas duas sub retorna o primeiro registro da tabela ao invés de ir para proximo ou anterior como deveria. Private Sub ProximoRegistro() Dim cnnComando As New ADODB.Command Dim rsSelecao As New ADODB.Recordset With cnnComando .ActiveConnection = cnnLider .CommandType = adCmdText .CommandText = "Select * From Clientes WHERE Codigo_Cliente = " & TxtCodCliente.Text & ";" Set rsSelecao = .Execute If rsSelecao.EOF = True Then rsSelecao.MoveNext End If End With Mostrar Saida: 'elimina o comand e o recorset da memoria: Set rsSelecao = Nothing Set cnnComando = Nothing Exit Sub End Sub Private Sub RegistroAnterior() Dim cnnComando As New ADODB.Command Dim rsSelecao As New ADODB.Recordset With cnnComando .ActiveConnection = cnnLider .CommandType = adCmdText .CommandText = "Select * From Clientes WHERE Codigo_Cliente = " & TxtCodCliente.Text & ";" Set rsSelecao = .Execute If rsSelecao.BOF = True Then rsSelecao.MovePrevious End If End With Mostrar Saida: 'elimina o comand e o recorset da memoria: Set rsSelecao = Nothing Set cnnComando = Nothing Screen.MousePointer = vbDefault Exit Sub End Sub Private Sub Mostrar() Dim cnnComando As New ADODB.Command Dim rsSelecao As New ADODB.Recordset With cnnComando .ActiveConnection = cnnCetecInfServiços .CommandType = adCmdText .CommandText = "Select * From Clientes" Set rsSelecao = .Execute TxtCodCliente.Text = rsSelecao!Codigo_Cliente TxtNomeCliente.Text = rsSelecao!Nome TxtTel.Text = rsSelecao!Telefone TxtCidade.Text = rsSelecao!Cidade TxtDataInicioServico.Text = rsSelecao!Data_Inicio_Servico TxtHoraInicioServico.Text = rsSelecao!Hora_Inicio_Servico TxtProduto.Text = rsSelecao!Produto TxtMotivo.Text = rsSelecao!Motivo_Chamada TxtObs.Text = rsSelecao!Obs End With Saida: 'elimina o comand e o recorset da memoria: Set rsSelecao = Nothing Set cnnComando = Nothing Screen.MousePointer = vbDefault Exit Sub End Sub Private Sub Toolbar1_ButtonClick(ByVal Button As ComctlLib.Button) 'verifica qual botao foi clicado Select Case Button.Index Case 1 'botao gravar GravarDados Case 2 'botao limpar LimparDados Case 3 'botao excluir ExcluirRegistro Case 4 'botao retornar Unload Me Case 5 'botão próximo registro ProximoRegistro Case 6 'botão registro anterior RegistroAnterior End Select End Sub Se alguém puder me ajudar. Agradeço.