USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Fórum

  Visual Basic
Voltar
Autor Assunto:  Update com tabela no Access
cleyton_keu
PORTO ALEGRE
RS - BRASIL
Postada em 17/07/2006 14:44 hs            
Run-time error '91'
 
Object variable or with block variable not set
 
esse erro q dá.
Obrigado
     
cleyton_keu
PORTO ALEGRE
RS - BRASIL
Postada em 17/07/2006 14:48 hs            
Esse:
 
Private Sub btnSave_Click()
    ConectarBd
'verificar se algum campo está vazio
    If txtCod.Text = Empty Then
        MsgBox "O campo Código do Fornecedor não foi preenchido.", vConfMsg, "Erro"
        vErro = True
    End If
   
    If txtCNPJ.Text = Empty Then
        MsgBox "O campo CNPJ não foi preenchido.", vConfMsg, "Erro"
        vErro = True
    End If
   
    If txtForn.Text = Empty Then
        MsgBox "O campo Fornecedor não foi preenchido.", vConfMsg, "Erro"
        vErro = True
    End If
   
    If txtMat.Text = Empty Then
        MsgBox "O campo Material não foi preenchido.", vConfMsg, "Erro"
        vErro = True
    End If
   
    If txtCont.Text = Empty Then
        MsgBox "O campo Contato não foi preenchido.", vConfMsg, "Erro"
        vErro = True
    End If
   
    If txtCarg.Text = Empty Then
        MsgBox "O campo Cargo não foi preenchido.", vConfMsg, "Erro"
        vErro = True
    End If
   
    If txtTelCom.Text = Empty Then
        MsgBox "O campo Telefone Comercial não foi preenchido.", vConfMsg, "Erro"
        vErro = True
    End If
   
    If txtTelCel.Text = Empty Then
        MsgBox "O campo Contato não foi preenchido.", vConfMsg, "Erro"
        vErro = True
    End If
   
    If txtEmail.Text = Empty Then
        MsgBox "O campo Contato não foi preenchido.", vConfMsg, "Erro"
        vErro = True
    End If
If txtCod.Text = Empty Or txtCNPJ.Text = Empty Or txtForn.Text = Empty Or txtMat.Text = Empty Or txtCont.Text = Empty Or txtCarg.Text = Empty Or txtTelCom.Text = Empty Or txtTelCel.Text = Empty Or txtEmail.Text = Empty Then
    MsgBox "Favor preencher os dados.", vConfMsg, "Erro"
Else
'Inserção dos dados
Cnn.Execute "INSERT INTO Fornecedor(Cod, CNPJ, Fornecedor, Material, Contato, Cargo, Tel, Tel_Cel, Email) VALUES (" & txtCod & ",'" & txtCNPJ & "','" & txtForn & "','" & txtMat & "','" & txtCont & "','" & txtCarg & "','" & txtTelCom & "','" & txtTelCel & "','" & txtEmail & "')"
End If
'apagar os campos depois de salvar na base de dados
txtCod.Text = Empty
txtCNPJ.Text = Empty
txtForn.Text = Empty
txtMat.Text = Empty
txtCont.Text = Empty
txtCarg.Text = Empty
txtTelCom.Text = Empty
txtTelCel.Text = Empty
txtEmail.Text = Empty
End Sub
 
obrigado
     
ghost_jlp
Pontos: 2843 Pontos: 2843 Pontos: 2843 Pontos: 2843
SÃO PAULO
SP - BRASIL
Postada em 17/07/2006 14:51 hs            
O erro acontece nesta linha??

Cnn.Execute "INSERT INTO Fornecedor(Cod, CNPJ, Fornecedor, Material, Contato, Cargo, Tel, Tel_Cel, Email) VALUES (" & txtCod & ",'" & txtCNPJ & "','" & txtForn & "','" & txtMat & "','" & txtCont & "','" & txtCarg & "','" & txtTelCom & "','" & txtTelCel & "','" & txtEmail & "')"
     
cleyton_keu
PORTO ALEGRE
RS - BRASIL
Postada em 17/07/2006 15:34 hs            
Sim, engraçado q passei o breakpoint e os valores chegam em txtCod, txtCNPJ.....
 
mas continua com erro
abraço
     
ghost_jlp
Pontos: 2843 Pontos: 2843 Pontos: 2843 Pontos: 2843
SÃO PAULO
SP - BRASIL
Postada em 17/07/2006 15:41 hs            
O objeto Cnn não está instanciado...
Esse ConectarBd é uma procedure?? Onde ela está? Se é qual o escopo dela? É global ou privada.
     
cleyton_keu
PORTO ALEGRE
RS - BRASIL
Postada em 17/07/2006 15:46 hs            
eu criei no módulo a ConectarBD, esse é o código, qdo vc fala instanciado, como assim?
 
Public Sub ConectarBd()
On Error GoTo final
Dim sPath As String
'***Abrindo a base de dados
Set cnBd = New ADODB.Connection
cnBd.CursorLocation = adUseClient '**O cursor será gerado ao lado do cliente - será gerado um arquivo temporário no cache da máquina
sPath = App.Path & "SisMaCo.mdb"
cnBd.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sPath
Screen.MousePointer = 0
Exit Sub
final:
MsgBox Err.Description, vbInformation, Err.Number
End Sub
     
Página(s): 2/3     « ANTERIOR    PRÓXIMA »


Seu Nome:

Seu eMail:

ALTERAR PARA MODO HTML
Mensagem:

[:)] = 
[:P] = 
[:(] = 
[;)] = 

HTML DESLIGADO

     
 VOLTAR

  



CyberWEB Network Ltda.    © Copyright 2000-2025   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página