Jump to content

caguerra

Members
  • Content count

    4
  • Joined

  • Last visited

Everything posted by caguerra

  1. Eu não tenho muita experiência no desenvolver um código VBA. Estou tentandocriar um DataBase, mas está indo totalmente muito bem.Os dados que eu preciso já está no arquivo do excelEu estu tentando atualizar a lista, adicionar, excluir pessoasou itens, mas está indo tudo errado ele nao adiciona ou muda nenhum dados da planilhaO botão (pesquisa, adicionar e outros funcionam,mas não fazem a ação corretaEu não sei o que eu fiz de erradodesde ja agardeco pela ajuda Option Explicit Dim blnNew As Boolean Dim TRows, i As Long Private Sub AddNew_Click() blnNew = True TextVendor.Text = "" TextPON.Text = "" TextPartNo.Text = "" TextSN.Text = "" TextItemCondition.Text = "" TextDescription.Text = "" TextPOP.Text = "" TextDR.Text = "" CloseButton.Caption = "Cancel" SaveButton.Enabled = False DeleteButton.Enabled = False End Sub Private Sub CloseButton_Click() If CloseButton.Caption = "Close" Then Unload Me Else CloseButton.Caption = "Close" AddNew.Enabled = True DeleteButton.Enabled = True End If 'If Trim(TextVendor.Text) = "" Then 'MsgBox "Enter Vendor Name", vbCritical, "Save" 'End If 'Call prSave End Sub Private Sub DeleteButton_Click() TRows = Worksheets("Inventory Assets").Range("A1").CurrentRegion.Rows.Count Dim strDel strDel = MsgBox("Delete ?", vbYesNo, "Delete") If strDel = vbYes Then For i = 2 To TRows If Trim(Worksheets("Inventory Assets").Cells(i, 1).Value) = Trim(VendorSelect.Text) Then 'Sheet1.Range(i & ":" & i).Delete Worksheets("Inventory Assets").Range(i & ":" & i).Delete TextVendor.Text = "" TextPON.Text = "" TextPartNo.Text = "" TextSN.Text = "" TextItemCondition.Text = "" TextDescription.Text = "" TextPOP.Text = "" TextDR.Text = "" Call ComboBoxFill Exit For End If Next i If Trim(VendorSelect.Text) = "" Then SaveButton.Enabled = False DeleteButton.Enabled = False Else SaveButton.Enabled = True DeleteButton.Enabled = True End If ' If Trim(PON.Text) = "" Then ' cmdSave.Enabled = False ' cmdDelete.Enabled = False ' Else ' cmdSave.Enabled = True ' cmdDelete.Enabled = True ' End If ' If Trim(PartNoSelect.Text) = "" Then ' cmdSave.Enabled = False ' cmdDelete.Enabled = False ' Else ' cmdSave.Enabled = True ' cmdDelete.Enabled = True ' End If ' If Trim(SNSelect.Text) = "" Then ' cmdSave.Enabled = False ' cmdDelete.Enabled = False ' Else ' cmdSave.Enabled = True ' cmdDelete.Enabled = True ' End If ' If Trim(ItemCondtionSelect.Text) = "" Then ' cmdSave.Enabled = False ' cmdDelete.Enabled = False ' Else ' cmdSave.Enabled = True ' cmdDelete.Enabled = True ' End If ' If Trim(DescriptionSelect.Text) = "" Then ' cmdSave.Enabled = False ' cmdDelete.Enabled = False ' Else ' cmdSave.Enabled = True ' cmdDelete.Enabled = True ' End If ' If Trim(POPSelect.Text) = "" Then ' cmdSave.Enabled = False ' cmdDelete.Enabled = False ' Else ' cmdSave.Enabled = True ' cmdDelete.Enabled = True ' End If ' If Trim(DRSelect.Text) = "" Then ' cmdSave.Enabled = False ' cmdDelete.Enabled = False ' Else ' cmdSave.Enabled = True ' cmdDelete.Enabled = True ' End If End If End Sub Private Sub SaveButton_Click() If Trim(TextVendor.Text) = "" Then MsgBox "Enter Vendor Name", vbCritical, "Save" End If Call prSave End Sub Private Sub SearchButton_Click() blnNew = False TextVendor.Text = "" TextPON.Text = "" TextPartNo.Text = "" TextSN.Text = "" TextItemCondition.Text = "" TextDescription.Text = "" TextPOP.Text = "" TextDR.Text = "" TRows = Worksheets("Inventory Assets").Range("A3").CurrentRegion.Rows.Count For i = 3 To TRows If Val(Trim(Worksheets("Inventory Assets").Cells(i, 1).Value)) = Val(Trim(VendorSelect.Text)) Then TextVendor.Text = Worksheets("Inventory Assets").Cells(i, 1).Value TextPON.Text = Worksheets("Inventory Assets").Cells(i, 2).Value TextPartNo.Text = Worksheets("Inventory Assets").Cells(i, 3).Value TextSN.Text = Worksheets("Inventory Assets").Cells(i, 4).Value TextItemCondition.Text = Worksheets("Inventory Assets").Cells(i, 5).Value TextDescription.Text = Worksheets("Inventory Assets").Cells(i, 6).Value TextPOP.Text = Worksheets("Inventory Assets").Cells(i, 7).Value TextDR.Text = Worksheets("Inventory Assets").Cells(i, 8).Value Exit For End If Next i If TextVendor.Text = "" Then Else SaveButton.Enabled = True DeleteButton.Enabled = True End If End Sub Private Sub prSave() If blnNew = True Then TRows = Worksheets("Inventory Assets").Range("A1").CurrentRegion.Rows.Count With Worksheets("Inventory Assets").Range("A1") .Offset(TRows, 0).Value = TextVendor.Text .Offset(TRows, 1).Value = TextPON.Text .Offset(TRows, 2).Value = TextPartNo.Text .Offset(TRows, 3).Value = TextSN.Text .Offset(TRows, 4).Value = TextItemCondition.Text .Offset(TRows, 5).Value = TextDescription.Text .Offset(TRows, 6).Value = TextPOP.Text .Offset(TRows, 7).Value = TextDR.Text End With TextVendor.Text = "" TextPON.Text = "" TextPartNo.Text = "" TextSN.Text = "" TextItemCondition.Text = "" TextDescription.Text = "" TextPOP.Text = "" TextDR.Text = "" Call ComboBoxFill Else For i = 2 To TRows If Trim(Worksheets("Inventory Assets").Cells(i, 1).Value) = (VendorSelect.Text) Then Worksheets("Inventory Assets").Cells(i, 1).Value = TextVendor.Text Worksheets("Inventory Assets").Cells(i, 2).Value = TextPOP.Text Worksheets("Inventory Assets").Cells(i, 3).Value = TextPartNo.Text Worksheets("Inventory Assets").Cells(i, 4).Value = TextSN.Text Worksheets("Inventory Assets").Cells(i, 5).Value = TextItemCondition.Text Worksheets("Inventory Assets").Cells(i, 6).Value = TextDescription.Text Worksheets("Inventory Assets").Cells(i, 7).Value = TextPOP.Text Worksheets("Inventory Assets").Cells(i, 8).Value = TextDR.Text TextVendor.Text = "" TextPOP.Text = "" TextPartNo.Text = "" TextSN.Text = "" TextItemCondition.Text = "" TextDescription.Text = "" TextPOP.Text = "" TextDR.Text = "" Exit For End If Next i End If blnNew = False End Sub Private Sub ComboBoxFill() TRows = Worksheets("Inventory Assets").Range("A1").CurrentRegion.Rows.Count VendorSelect.Clear For i = 2 To TRows ComboBox.AddItem.Worksheets("Inventory Assets").Cells(i, 1).Value Next i End Sub ''Private Sub ComboBoxFill() ' TRows = Workplace("Inventory Assets").Range("A1").CurrentRegion.Rows.Count ' PON.Clear ' For i = 2 To TRows ' ComboBox.AddItem.Workesheets("Inventory Assets").Cells(i, 1).Value ' Next i 'End Sub ''Private Sub ComboBoxFill() ' TRows = Workplace("Inventory Assets").Range("A1").CurrentRegion.Rows.Count ' PartNoSelect.Clear ' For i = 2 To TRows ' ComboBox.AddItem.Workesheets("Inventory Assets").Cells(i, 1).Value ' Next i 'End Sub ''Private Sub ComboBoxFill() ' TRows = Workplace("Inventory Assets").Range("A1").CurrentRegion.Rows.Count ' SNSelect.Clear ' For i = 2 To TRows ' ComboBox.AddItem.Workesheets("Inventory Assets").Cells(i, 1).Value ' Next i 'End Sub ''Private Sub ComboBoxFill() ' TRows = Workplace("Inventory Assets").Range("A1").CurrentRegion.Rows.Count ' ItemCondtionSelect.Clear ' For i = 2 To TRows ' ComboBox.AddItem.Workesheets("Inventory Assets").Cells(i, 1).Value ' Next i 'End Sub ''Private Sub ComboBoxFill() ' TRows = Workplace("Inventory Assets").Range("A1").CurrentRegion.Rows.Count ' DescriptionSelect.Clear ' For i = 2 To TRows ' ComboBox.AddItem.Workesheets("Inventory Assets").Cells(i, 1).Value ' Next i 'End Sub ''Private Sub ComboBoxFill() ' TRows = Workplace("Inventory Assets").Range("A1").CurrentRegion.Rows.Count ' POPSelect.Clear ' For i = 2 To TRows ' ComboBox.AddItem.Workesheets("Inventory Assets").Cells(i, 1).Value ' Next i 'End Sub ''Private Sub ComboBoxFill() ' TRows = Workplace("Inventory Assets").Range("A1").CurrentRegion.Rows.Count ' DRSelect.Clear ' For i = 2 To TRows ' ComboBox.AddItem.Workesheets("Inventory Assets").Cells(i, 1).Value ' Next i 'End Sub 'Rows(7).Select 'Columns(2).Select( para pegar a coluna e fileira Private Sub Test_Initialize() Call prCommBoxFill SaveButton.Enable = False DeleteButton.Enable = False End Sub Private Sub VendorSelect_Change() TRows = Workplace("Inventory Assets").Range("A1").CurrentRegion.Rows.Count VendorSelect.Clear For i = 2 To TRows ComboBox.AddItem.Worksheets("Inventory Assets").Cells(i, 1).Value Next i End Sub Private Sub PONSelect_Change() TRows = Workplace("Inventory Assets").Range("B2").CurrentRegion.Rows.Count PON.Clear For i = 2 To TRows ComboBox.AddItem.Worksheets("Inventory Assets").Cells(i, 1).Value Next i End Sub Private Sub PartNoSelect_Change() 'Private Sub ComboBoxFill() TRows = Workplace("Inventory Assets").Range("A1").CurrentRegion.Rows.Count PartNoSelect.Clear For i = 2 To TRows ComboBox.AddItem.Worksheets("Inventory Assets").Cells(i, 1).Value Next i End Sub Private Sub SNSelect_Change() 'Private Sub ComboBoxFill() TRows = Workplace("Inventory Assets").Range("A1").CurrentRegion.Rows.Count SNSelect.Clear For i = 2 To TRows ComboBox.AddItem.Worksheets("Inventory Assets").Cells(i, 1).Value Next i End Sub Private Sub ItemConditionSelect_Change() 'Private Sub ComboBoxFill() TRows = Workplace("Inventory Assets").Range("A1").CurrentRegion.Rows.Count ItemCondtionSelect.Clear For i = 2 To TRows ComboBox.AddItem.Workesheets("Inventory Assets").Cells(i, 1).Value Next i End Sub Private Sub DescriptionSelect_Change() 'Private Sub ComboBoxFill() TRows = Workplace("Inventory Assets").Range("A1").CurrentRegion.Rows.Count DescriptionSelect.Clear For i = 2 To TRows ComboBox.AddItem.Workesheets("Inventory Assets").Cells(i, 1).Value Next i End Sub Private Sub POPSelect_Change() 'Private Sub ComboBoxFill() TRows = Workplace("Inventory Assets").Range("A1").CurrentRegion.Rows.Count POPSelect.Clear For i = 2 To TRows ComboBox.AddItem.Worksheets("Inventory Assets").Cells(i, 1).Value Next i End Sub Private Sub DRSelect_Change() 'Private Sub ComboBoxFill() TRows = Workplace("Inventory Assets").Range("A1").CurrentRegion.Rows.Count DRSelect.Clear For i = 2 To TRows ComboBox.AddItem.Workesheets("Inventory Assets").Cells(i, 1).Value Next i End Sub Private Sub Search_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) End Sub
×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.