You are on page 1of 5

MODIFICAR PRODUCTO

private Sub ComboBox1_Change()


Dim Fila As Integer
Dim Final As Integer

If ComboBox1.Value = "" Then


Me.txt_Nombre = ""
Me.txt_Descrip = ""
End If

For Fila = 2 To 1000


If Hoja2.Cells(Fila, 1) = "" Then
Final = Fila - 1
Exit For
End If
Next

For Fila = 2 To Final


If ComboBox1 = Hoja2.Cells(Fila, 1) Then
Me.txt_Nombre = Hoja2.Cells(Fila, 2)
Me.txt_Descrip = Hoja2.Cells(Fila, 3)
Exit For
End If
Next

End Sub
Private Sub ComboBox1_Enter()
Dim Fila As Integer
Dim Final As Integer
Dim Lista As String

For Fila = 1 To ComboBox1.ListCount


ComboBox1.RemoveItem 0
Next Fila

For Fila = 2 To 1000


If Hoja2.Cells(Fila, 1) = "" Then
Final = Fila - 1
Exit For
End If
Next

For Fila = 2 To Final


Lista = Hoja2.Cells(Fila, 1)
ComboBox1.AddItem (Lista)
Next
End Sub

Private Sub CommandButton1_Click()


Dim Fila As Integer
Dim Final As Integer

For Fila = 2 To 1000


If Hoja2.Cells(Fila, 1) = "" And Hoja3.Cells(Fila, 1) = "" And Hoja5.Cells(Fila, 1) = "" Then
Final = Fila - 1
Exit For
End If
Next

For Fila = 2 To Final


If Me.ComboBox1 = Hoja2.Cells(Fila, 1) Then
Hoja2.Cells(Fila, 2) = Me.txt_Nombre
Hoja2.Cells(Fila, 3) = Me.txt_Descrip
Exit For
End If
Next
'-------------------------------------------------
For Fila = 2 To Final
If Me.ComboBox1 = Hoja3.Cells(Fila, 1) Then
Hoja3.Cells(Fila, 2) = Me.txt_Nombre

End If
Next

For Fila = 2 To Final


If Me.ComboBox1 = Hoja5.Cells(Fila, 1) Then
Hoja5.Cells(Fila, 2) = Me.txt_Nombre
Exit For
End If
Next

'-------------------------------------------------
Me.ComboBox1 = ""
Me.txt_Nombre = ""
Me.txt_Descrip = ""

End Sub

Private Sub CommandButton2_Click()


Unload Me
End Sub

REGISTRAR PRODUCTO
Private Sub CommandButton1_Click()
Dim Fila As Integer
Dim Final As Integer
Dim Registro As Integer

For Fila = 1 To 1000


If Hoja2.Cells(Fila, 1) = "" Then
Final = Fila
Exit For
End If
Next

For Registro = 2 To Final


If Hoja2.Cells(Registro, 1) = Me.txt_CodProd Then
Me.txt_CodProd.BackColor = &H8080FF
MsgBox ("Registro ya existe" + Chr(13) + "Ingrese un código diferente")
Me.txt_CodProd.SetFocus
Exit Sub
Exit For
End If
Next

If MsgBox("Son correctos los datos?" + Chr(13) + "Desea proceder?", vbOKCancel) = vbOK Then
Me.txt_CodProd.BackColor = &HFFFFFF
Hoja2.Cells(Final, 1) = Me.txt_CodProd
Hoja2.Cells(Final, 2) = Me.txt_Nombre
Hoja2.Cells(Final, 3) = Me.txt_Descrip
'-----------------------------------------------
Hoja5.Cells(Final, 1) = Me.txt_CodProd
Hoja5.Cells(Final, 2) = Me.txt_Nombre
Hoja5.Cells(Final, 3) = 0
'-----------------------------------------------
Me.txt_CodProd = ""
Me.txt_Nombre = ""
Me.txt_Descrip = ""
Me.txt_CodProd.SetFocus
Else
Exit Sub
End If
End Sub

Private Sub CommandButton2_Click()


Unload Me
End Sub

You might also like