Notifications
Clear all

erro 13

5 Posts
2 Usuários
0 Reactions
894 Visualizações
(@andersonps)
Posts: 4
New Member
Topic starter
 

boa noite sou novo no forum estou fazendo umas video aula controle de estoque fiz o form de cadastro e no de entrada estou com o seguinte erro quando clico no botão novo ele me da o erro em tempo de execução '13': tipo de dados incompatíveis vou postar o código mas o erro se encontra em cod = textbox3 segue o código abaixo




Private Sub TextBox2_Change()

End Sub

Private Sub TextBox3_Change()

End Sub

Private Sub TextBox3_(ByVal Cancel As MSForms.ReturnBoolean)
Dim cod As Single
cod = TextBox3
TextBox4 = Application.WorksheetFunction.VLookup(cod, Plan2.Range("A:Z"), 2, 0)
End Sub

Private Sub TEXTBOX5_Change()

End Sub

Private Sub CommandButton1_Click()

If TextBox2 = "" Or TextBox3 = "" Or TextBox4 = "" Or TextBox5 = "" Then
MsgBox "EXISTEM CAMPOS A SEREM DIGITADOS", vbCritical, "ATENÇÃO"
Else


Dim DATA As Date
Dim Valor As Single
DATA = TextBox2
Valor = TextBox6

If L1 = "NOVO" Then
MSG = MsgBox("CONFIRMA A ENTRADA DO PRODUTO?", vbOKCancel, "ATENÇÃO")
If MSG = 1 Then

A = Application.WorksheetFunction.CountA(Plan3.Columns(1)) + 1
Plan3.Cells(A, 1) = TextBox1.Text
Plan3.Cells(A, 2) = DATA
Plan3.Cells(A, 3) = TextBox3
Plan3.Cells(A, 4) = TextBox4
Plan3.Cells(A, 5) = TextBox5.Text
Plan3.Cells(A, 6) = Valor
CommandButton2_Click
MsgBox "ENTRADA REALIZADA COM SUCESSO!!!", vbInformation, "SERVCAMP"

Else
End If
Else

If L1 = "ALTERAR" Then
MS = MsgBox("CONFIRMA A ALTERAÇÃO DO PRODUTO?", vbOKCancel, "ATENÇÃO")
If MS = 1 Then

Dim CORR As Single
CORR = TextBox1
B = Application.WorksheetFunction.Match(CORR, Plan3.Columns(1), 0)
Plan3.Cells(B, 2) = DATA
Plan3.Cells(B, 3) = TextBox3
Plan3.Cells(B, 4) = TextBox4
Plan3.Cells(B, 5) = TextBox5.Text
Plan3.Cells(B, 6) = Valor
CommandButton2_Click
Else
End If
End If
End If
End If


End Sub

Private Sub CommandButton2_Click()
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False

CommandButton3.Enabled = True
CommandButton4.Enabled = True
CommandButton5.Enabled = True
CommandButton6.Enabled = True
CommandButton1.Enabled = False
CommandButton2.Enabled = False



End Sub

Private Sub CommandButton3_Click()
L1 = "NOVO"
TextBox1 = WorksheetFunction.Max(Plan3.Columns(1)) + 1
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
TextBox6.Enabled = True

TextBox2 = Date
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
CommandButton3.Enabled = False
CommandButton4.Enabled = False
CommandButton5.Enabled = False
CommandButton6.Enabled = False
CommandButton1.Enabled = True
CommandButton2.Enabled = True
End Sub

Private Sub CommandButton4_Click()
L1 = "ALTERAR"
TextBox1.Enabled = True
CommandButton3.Enabled = False
CommandButton4.Enabled = False
CommandButton5.Enabled = False
CommandButton6.Enabled = False
CommandButton1.Enabled = True
CommandButton2.Enabled = True

End Sub

Private Sub CommandButton5_Click()
L1 = "CONSULTAR"
TextBox1.Enabled = True
CommandButton3.Enabled = False
CommandButton4.Enabled = False
CommandButton5.Enabled = False
CommandButton6.Enabled = False
CommandButton1.Enabled = True
CommandButton2.Enabled = True
End Sub

Private Sub CommandButton6_Click()
L1 = "EXCLUIR"
TextBox1.Enabled = True
CommandButton3.Enabled = False
CommandButton4.Enabled = False
CommandButton5.Enabled = False
CommandButton6.Enabled = False
CommandButton1.Enabled = True
CommandButton2.Enabled = True
End Sub





Private Sub Label1_Click()

End Sub

Private Sub Label6_Click()

End Sub

Private Sub TEXTBOX1_Change()
    
End Sub

Private Sub TEXTBOX1_(ByVal Cancel As MSForms.ReturnBoolean)
    On Error GoTo trata

Dim cod As Single
cod = TextBox1
TextBox2 = Application.WorksheetFunction.VLookup(cod, Plan3.Range("a:z"), 2, 0)
TextBox3 = Application.WorksheetFunction.VLookup(cod, Plan3.Range("a:z"), 3, 0)
TextBox4 = Application.WorksheetFunction.VLookup(cod, Plan3.Range("a:z"), 4, 0)
TextBox5 = Application.WorksheetFunction.VLookup(cod, Plan3.Range("a:z"), 5, 0)
TextBox6 = Application.WorksheetFunction.VLookup(cod, Plan3.Range("a:z"), 6, 0)
TextBox6 = Format(TextBox6, "R$ #,##0.00")
TextBox2 = Format(TextBox2, "dd/mm/yyyy")
If L1 = "CONSULTAR" Then
TextBox1.Enabled = False
Else
If L1 = "ALTERAR" Then
TextBox1.Enabled = False
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
TextBox6.Enabled = True
Else
If L1 = "EXCLUIR" Then
MSG = MsgBox("CONFIRMA A EXCLUSÃO DO PRODUTO?", vbOKCancel, "ATENÇÃO")
If MSG = 1 Then
Dim CORR As Single
CORR = TextBox1
B = Application.WorksheetFunction.Match(CORR, Plan3.Columns(1), 0)
Plan3.Rows(2).Delete Shift:=xlUp
Plan3.Rows(B).Delete Shift:=xlUp
CommandButton2_Click
Else

End If
End If
End If
End If
 'Sub
trata:
MsgBox "Produto não Cadastrado", vbInformation, "ServCamp"


End Sub

Private Sub TEXTBOX4_Change()

End Sub

Private Sub TEXTBOX4_(ByVal Cancel As MSForms.ReturnBoolean)
TextBox4 = Format(TextBox4, "R$ #,##0.00")


End Sub

Private Sub TextBox5_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim cod As Single
cod = TextBox3
TextBox6 = Application.WorksheetFunction.VLookup(cod, Plan2.Range("A:Z"), 4, 0) * TextBox5

End Sub

Private Sub TextBox6_Change()

End Sub

Private Sub UserForm_Click()

End Sub

Private Sub UserForm_Initialize()


End Sub


 
Postado : 13/07/2015 5:09 pm
Fernando Fernandes
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

anderson, pelo que vi, você apagou o complemento do evento do textbox3 :

Private Sub TextBox3_faltaOevento(ByVal Cancel As MSForms.ReturnBoolean)

Que eu acredito ser TextBox3_Exit ou TextBox3_BeforeUpdate, e se olhar direito, verá que nas rotinas que postou, a maioria dos textbox estão sem este complemento o que irá gerar novos erros.

[]s

Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel

 
Postado : 13/07/2015 8:12 pm
Fernando Fernandes
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Alem disso, a definição da variável "cod As Single", requer que textbox3 sempre tenha um valor, se estiver em branco/nulo gerará o erro 13

Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel

 
Postado : 14/07/2015 7:32 am
(@andersonps)
Posts: 4
New Member
Topic starter
 

anderson, pelo que vi, você apagou o complemento do evento do textbox3 :

Private Sub TextBox3_faltaOevento(ByVal Cancel As MSForms.ReturnBoolean)

Que eu acredito ser TextBox3_Exit ou TextBox3_BeforeUpdate, e se olhar direito, verá que nas rotinas que postou, a maioria dos textbox estão sem este complemento o que irá gerar novos erros.

[]s

boa noite sou novo no forum estou fazendo umas video aula controle de estoque fiz o form de cadastro e no de entrada estou com o seguinte erro quando clico no botão novo ele me da o erro em tempo de execução '13': tipo de dados incompatíveis vou postar o código mas o erro se encontra em cod = textbox3 segue o código abaixo




Private Sub TextBox2_Change()

End Sub

Private Sub TextBox3_Change()

End Sub

Private Sub TextBox3_(ByVal Cancel As MSForms.ReturnBoolean)
Dim cod As Single
cod = TextBox3
TextBox4 = Application.WorksheetFunction.VLookup(cod, Plan2.Range("A:Z"), 2, 0)
End Sub

Private Sub TEXTBOX5_Change()

End Sub

Private Sub CommandButton1_Click()

If TextBox2 = "" Or TextBox3 = "" Or TextBox4 = "" Or TextBox5 = "" Then
MsgBox "EXISTEM CAMPOS A SEREM DIGITADOS", vbCritical, "ATENÇÃO"
Else


Dim DATA As Date
Dim Valor As Single
DATA = TextBox2
Valor = TextBox6

If L1 = "NOVO" Then
MSG = MsgBox("CONFIRMA A ENTRADA DO PRODUTO?", vbOKCancel, "ATENÇÃO")
If MSG = 1 Then

A = Application.WorksheetFunction.CountA(Plan3.Columns(1)) + 1
Plan3.Cells(A, 1) = TextBox1.Text
Plan3.Cells(A, 2) = DATA
Plan3.Cells(A, 3) = TextBox3
Plan3.Cells(A, 4) = TextBox4
Plan3.Cells(A, 5) = TextBox5.Text
Plan3.Cells(A, 6) = Valor
CommandButton2_Click
MsgBox "ENTRADA REALIZADA COM SUCESSO!!!", vbInformation, "SERVCAMP"

Else
End If
Else

If L1 = "ALTERAR" Then
MS = MsgBox("CONFIRMA A ALTERAÇÃO DO PRODUTO?", vbOKCancel, "ATENÇÃO")
If MS = 1 Then

Dim CORR As Single
CORR = TextBox1
B = Application.WorksheetFunction.Match(CORR, Plan3.Columns(1), 0)
Plan3.Cells(B, 2) = DATA
Plan3.Cells(B, 3) = TextBox3
Plan3.Cells(B, 4) = TextBox4
Plan3.Cells(B, 5) = TextBox5.Text
Plan3.Cells(B, 6) = Valor
CommandButton2_Click
Else
End If
End If
End If
End If


End Sub

Private Sub CommandButton2_Click()
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False

CommandButton3.Enabled = True
CommandButton4.Enabled = True
CommandButton5.Enabled = True
CommandButton6.Enabled = True
CommandButton1.Enabled = False
CommandButton2.Enabled = False



End Sub

Private Sub CommandButton3_Click()
L1 = "NOVO"
TextBox1 = WorksheetFunction.Max(Plan3.Columns(1)) + 1
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
TextBox6.Enabled = True

TextBox2 = Date
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
CommandButton3.Enabled = False
CommandButton4.Enabled = False
CommandButton5.Enabled = False
CommandButton6.Enabled = False
CommandButton1.Enabled = True
CommandButton2.Enabled = True
End Sub

Private Sub CommandButton4_Click()
L1 = "ALTERAR"
TextBox1.Enabled = True
CommandButton3.Enabled = False
CommandButton4.Enabled = False
CommandButton5.Enabled = False
CommandButton6.Enabled = False
CommandButton1.Enabled = True
CommandButton2.Enabled = True

End Sub

Private Sub CommandButton5_Click()
L1 = "CONSULTAR"
TextBox1.Enabled = True
CommandButton3.Enabled = False
CommandButton4.Enabled = False
CommandButton5.Enabled = False
CommandButton6.Enabled = False
CommandButton1.Enabled = True
CommandButton2.Enabled = True
End Sub

Private Sub CommandButton6_Click()
L1 = "EXCLUIR"
TextBox1.Enabled = True
CommandButton3.Enabled = False
CommandButton4.Enabled = False
CommandButton5.Enabled = False
CommandButton6.Enabled = False
CommandButton1.Enabled = True
CommandButton2.Enabled = True
End Sub





Private Sub Label1_Click()

End Sub

Private Sub Label6_Click()

End Sub

Private Sub TEXTBOX1_Change()
    
End Sub

Private Sub TEXTBOX1_(ByVal Cancel As MSForms.ReturnBoolean)
    On Error GoTo trata

Dim cod As Single
cod = TextBox1
TextBox2 = Application.WorksheetFunction.VLookup(cod, Plan3.Range("a:z"), 2, 0)
TextBox3 = Application.WorksheetFunction.VLookup(cod, Plan3.Range("a:z"), 3, 0)
TextBox4 = Application.WorksheetFunction.VLookup(cod, Plan3.Range("a:z"), 4, 0)
TextBox5 = Application.WorksheetFunction.VLookup(cod, Plan3.Range("a:z"), 5, 0)
TextBox6 = Application.WorksheetFunction.VLookup(cod, Plan3.Range("a:z"), 6, 0)
TextBox6 = Format(TextBox6, "R$ #,##0.00")
TextBox2 = Format(TextBox2, "dd/mm/yyyy")
If L1 = "CONSULTAR" Then
TextBox1.Enabled = False
Else
If L1 = "ALTERAR" Then
TextBox1.Enabled = False
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
TextBox6.Enabled = True
Else
If L1 = "EXCLUIR" Then
MSG = MsgBox("CONFIRMA A EXCLUSÃO DO PRODUTO?", vbOKCancel, "ATENÇÃO")
If MSG = 1 Then
Dim CORR As Single
CORR = TextBox1
B = Application.WorksheetFunction.Match(CORR, Plan3.Columns(1), 0)
Plan3.Rows(2).Delete Shift:=xlUp
Plan3.Rows(B).Delete Shift:=xlUp
CommandButton2_Click
Else

End If
End If
End If
End If
 'Sub
trata:
MsgBox "Produto não Cadastrado", vbInformation, "ServCamp"


End Sub

Private Sub TEXTBOX4_Change()

End Sub

Private Sub TEXTBOX4_(ByVal Cancel As MSForms.ReturnBoolean)
TextBox4 = Format(TextBox4, "R$ #,##0.00")


End Sub

Private Sub TextBox5_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim cod As Single
cod = TextBox3
TextBox6 = Application.WorksheetFunction.VLookup(cod, Plan2.Range("A:Z"), 4, 0) * TextBox5

End Sub

Private Sub TextBox6_Change()

End Sub

Private Sub UserForm_Click()

End Sub

Private Sub UserForm_Initialize()


End Sub


 
Postado : 15/07/2015 8:15 pm
(@andersonps)
Posts: 4
New Member
Topic starter
 

MUITO OBRIGADO AMIGO FALTA DE ATENÇÃO MINHA

 
Postado : 15/07/2015 8:16 pm