Beruflich Dokumente
Kultur Dokumente
A melhor forma de disponibilizar estas informaes fazer o upload do(s) arquivo(s) num servio de virtual disk como o www.rapidshare.com ou o www.4shared.com. [ ]s Adilson Soledade Blog: http://usuariosdoexcel.wordpress.com/ A resposta foi til? Vote no boto ao lado filman Membro Status:
por filman 14 Mai 2009 Mensagens: 28 Registro: isso mesmo gostaria de excluir da tabela do access pelo VBA do Excel ! 04 Mai 2009 Observe meu cdigo de cadastro. Karma: ------CADASTRO PRODUTOS-----http://img222.imageshack.us/img222/487/cadp.png [0] Cdigo: Selecionar tudo
Private Sub CmdAddProd_Click() Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Conn As ADODB.Connection StrCon As String Cox As String Cod As String Desc As String Embg As String Qtdd As String Eann As String IcmE As String IcmS As String Iva As String Red As String Pauta As String Class As String
Cox = ThisWorkbook.Path & "\" & "Cadastro.mdb" Cod = Trim(Tcod.Text) Desc = Trim(Tdesc.Text) Embg = Trim(TEmb.Text) Qtdd = Trim(TQtd.Text) Eann = Trim(TEan.Text) IcmE = Trim(TIcmEnt.Text) IcmS = Trim(TIcmSai.Text) Iva = Trim(TIva.Text) Red = Trim(TRed.Text) Pauta = Trim(TPauta.Text) Class = Trim(TClass.Text) If (Cod) = "" Then MsgBox "Por favor o cdigo obrigatrio!" Tcod.SetFocus Exit Sub Else If (Desc) = "" Then MsgBox "Por favor a descrio obrigatria!" Tdesc.SetFocus Exit Sub Else If (Embg) = "" Then
MsgBox "Por favor a obrigatria!" TEmb.SetFocus Exit Sub Else If (Qtdd) = "" Then MsgBox "Por favor a obrigatria!" TQtd.SetFocus Exit Sub Else If (Eann) = "" Then MsgBox "Por favor o TEan.SetFocus Exit Sub Else If (IcmE) = "" Then MsgBox "Por favor o TIcmEnt.SetFocus Exit Sub Else If (IcmS) = "" Then MsgBox "Por favor o TIcmSai.SetFocus Exit Sub End If End If End If End If End If End If End If
descrio da embalagem
quantidade da embalagem
ean obrigatrio!"
StrCon = "INSERT INTO Produtos (Codigo, Descricao, Emb, Qtd, Ean, IcmEnt, IcmSai, Iva, Reducao, Pauta, Classif) VALUES ('" & Cod & "','" & Desc & "','" & Embg & "','" & Qtdd & "','" & Eann & "','" & IcmE & "','" & IcmS & "','" & Iva & "','" & Red & "','" & Pauta & "','" & Class & "')" Set Conn = New ADODB.Connection With Conn .Provider = "Microsoft.Jet.OLEDB.4.0" .Open Cox End With Conn.Execute StrCon Conn.Close Set Conn = Nothing MsgBox "Registro salvo com sucesso! ", vbInformation, "Registro salvo!" Tcod.Text = vbNullString Tdesc.Text = vbNullString TEmb.Text = vbNullString TQtd.Text = vbNullString TEan.Text = vbNullString TIcmEnt.Text = vbNullString
TIcmSai.Text = vbNullString TIva.Text = vbNullString TRed.Text = vbNullString TPauta.Text = vbNullString TClass.Text = vbNullString Tcod.SetFocus End Sub
Cdigo: Selecionar tudo
Private Sub CmdAddFor_Click() Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Conn As ADODB.Connection StrCon As String Cox As String Cod As String Raz As String NFan As String Cnpjj As String Insc As String Ruaa As String Bai As String Nbr As String Cid As String Cepp As String Est As String Fon As String Comp As String
Cox = ThisWorkbook.Path & "\" & "Cadastro.mdb" Cod = Trim(Tcod.Text) Raz = Trim(TRaz.Text) NFan = Trim(TNFant.Text) Cnpjj = Trim(TCnpj.Text) Insc = (TInsc.Text) Ruaa = Trim(TRua.Text) Bai = Trim(TBairro.Text) Nbr = Trim(TNum.Text) Cid = Trim(TCid.Text) Cepp = Trim(TCep.Text) Est = Trim(TEst.Text) Fon = Trim(TFone.Text) Comp = Trim(TComplem.Text) If (Cod) = "" Then MsgBox "Por favor o cdigo obrigatrio!" Tcod.SetFocus Exit Sub
Else If (Raz) = "" Then MsgBox "Por favor a razo social obrigatria!" TRaz.SetFocus Exit Sub Else If (Cnpjj) = "" Then MsgBox "Por favor o cnpj obrigatrio!" TCnpj.SetFocus Exit Sub Else If (Insc) = "" Then MsgBox "Por favor a inscrio estadual obrigatria!" TInsc.SetFocus Exit Sub End If End If End If End If StrCon = "INSERT INTO Fornecedor (Codigo, Razao, NFant, Cnpj, Inscri, Rua, Bairro, Num, Cidade, Cep, Estado, Fone, Complem) VALUES ('" & Cod & "','" & Raz & "','" & NFan & "','" & Cnpjj & "','" & Insc & "','" & Ruaa & "','" & Bai & "','" & Nbr & "','" & Cid & "','" & Cepp & "','" & Est & "','" & Fon & "','" & Comp & "')" Set Conn = New ADODB.Connection With Conn .Provider = "Microsoft.Jet.OLEDB.4.0" .Open Cox End With Conn.Execute StrCon Conn.Close Set Conn = Nothing MsgBox "Registro salvo com sucesso! ", vbInformation, "Registro salvo!" Tcod.Text = vbNullString TRaz.Text = vbNullString TNFant.Text = vbNullString TCnpj.Text = vbNullString TInsc.Text = vbNullString TRua.Text = vbNullString TBairro.Text = vbNullString TNum.Text = vbNullString TCid.Text = vbNullString TCep.Text = vbNullString TEst.Text = vbNullString TFone.Text = vbNullString TComplem.Text = vbNullString Tcod.SetFocus End Sub
Agora penso em criar um forme novo onde eu deleto da tabela o produto ou fornecedor. Sera que poderiam me ajudar? Agradecido pelas as ajudas Deus no escolhe os capacitados, capacita os escolhidos!!! O mistrio no um murro onde a inteligncia se esbarra, mas sim um oceano onde ela mergulha!!!
Olha meu caro, como te falei anteriormente pra trabalhar com o Access um pouco mais complicado, o ideal era disponibilizar um exemplo do seu arquivo como sugeriu o Adilson. Vou tentar te dar uma idia de como deve ser feito, e lembrando mais uma vez, QUALQUER OPERAO QUE VOC PRECISE FAZER, COM OS DADOS Mensagens:NO ACCESS, NECESSRIO EFETUAR A CONEXO. POR ISSO MUITO IMPORTANTE QUE ESTUDE 472 SOBRE O ASSUNTO. Registro: 06 Abr 2009 Karma: Sub EXCLUIR(Cod As String) Dim cnn As adodb.Connection [21] Dim rst As adodb.Recordset Dim strConn As String Dim strSQL As String On Error GoTo ERRO NOMEBD = ThisWorkbook.Path & "\SEUARQUIVO.MDB" Tabela = "NOMETABELA" strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & NOMEBD & ";Jet OLEDB:Database Password=703100385" Set cnn = New adodb.Connection cnn.Open strConn Set rst = New adodb.Recordset strSQL = "DELETE * FROM " & Tabela & " WHERE Codigo=" & Cod & ";" cnn.Execute strSQL Set rst = Nothing cnn.Close Set cnn = Nothing Set rst = Nothing MsgBox "REGISTRO EXCLUIDO!", vbInformation, "Excluso..." GoTo 100 'TRATAMENTO DE ERROS ERRO: MsgBox "MODULO ExcluirDados - PRODUTO" & Chr(13) & Err.Number & " - " & Err.Description, vbCritical, "Erro..." 'TratarErro '-------------------------------------------------------------------------------------------100 Userform1.txtCodigo.Value = "" Userform1.txtDescricao.Value = "" Userform1.txtValor.SetFocus
End Sub Espero que seja til. []'s Sub Guilherme_Initialize() If Me.Guima <> "" Then MsgBox "Obrigado pela fora " Else MsgBox "Conto com sua colaborao " End If End Sub