Hola etimados miembros del foro , tengo el siguiente problema , parece **maravilloso** pero no logro darme cuenta del error, cuando quiero registra un nuevo cliente a traves del fomulario este lo hace pero fila por medio , no lo hace como deberia uno debajo del ultimo el cod es :
Option Explicit
Dim CelEncontrada As Range
Dim CodigoAux As Variant
Private Sub Bot_Limpiar_Click()
Call ModClientes.LimpiarFormulario
End Sub
Private Sub Bot_Registrar_Click()
With frmClientes
If .TxtIdCliente.Value = "" Then
MsgBox "Digite el n° de documento del cliente"
.TxtIdCliente.SetFocus
Exit Sub
End If
If .TxtNombre.Value = "" Then
MsgBox "Digite el Nombre del cliente"
.TxtApellido.SetFocus
Exit Sub
End If
If .TxtApellido.Value = "" Then
MsgBox "Digite el Apellido del cliente"
.TxtApellido.SetFocus
Exit Sub
End If
If .TxtCel1.Value = "" Then
MsgBox "Digite el n° celular del cliente"
.TxtCel1.SetFocus
Exit Sub
End If
If .TxtDireccion.Value = "" Then
MsgBox "Digite la direccion del cliente"
.TxtDireccion.SetFocus
Exit Sub
End If
If .TxtLocalidad.Value = "" Then
MsgBox "Digite la localidad o ciudad del cliente"
.TxtLocalidad.SetFocus
Exit Sub
End If
If .TxtProvincia.Value = "" Then
MsgBox "Digite la provincia del cliente"
.TxtProvincia.SetFocus
Exit Sub
End If
If .TxtPuntoContac.Value = "" Then
MsgBox "Digite un punto de contacto"
.TxtPuntoContac.SetFocus
Exit Sub
End If
If .TxtRelacion.Value = "" Then
MsgBox "Digite que relacion tiene con el cliente"
.TxtRelacion.SetFocus
Exit Sub
End If
If .TxtCel2.Value = "" Then
MsgBox "Digite el n° de celular del punto de contacto"
.TxtCel2.SetFocus
Exit Sub
End If
End With
Dim Codigo As Variant
Dim ColCodigo As Range
Codigo = frmClientes.TxtIdCliente.Value
Set ColCodigo = Hoja3.ListObjects("Tab_Clientes").ListColumns(1).Range
Set CelEncontrada = ColCodigo.Find(what:=Codigo, After:=ColCodigo.Cells(1), LookAt:=xlPart)
If Not CelEncontrada Is Nothing Then
If MsgBox(" EL documento ya existe,¿quiere crearlo nuevamente?", vbYesNo) = vbNo Then
frmClientes.TxtIdCliente.SetFocus
Exit Sub
End If
End If
Set CelEncontrada = Hoja3.ListObjects("Tab_Clientes").ListRows.Add.Range.Cells(1)
Set CelEncontrada = Hoja3.ListObjects("Tab_Clientes").ListRows.Add.Range.Cells(1)
Hola etimados miembros del foro , tengo el siguiente problema , parece **maravilloso** pero no logro darme cuenta del error, cuando quiero registra un nuevo cliente a traves del fomulario este lo hace pero fila por medio , no lo hace como deberia uno debajo del ultimo el cod es :
Option Explicit
Dim CelEncontrada As Range
Dim CodigoAux As Variant
Private Sub Bot_Limpiar_Click()
Call ModClientes.LimpiarFormulario
End Sub
Private Sub Bot_Registrar_Click()
With frmClientes
If .TxtIdCliente.Value = "" Then
MsgBox "Digite el n° de documento del cliente"
.TxtIdCliente.SetFocus
Exit Sub
End If
If .TxtNombre.Value = "" Then
MsgBox "Digite el Nombre del cliente"
.TxtApellido.SetFocus
Exit Sub
End If
If .TxtApellido.Value = "" Then
MsgBox "Digite el Apellido del cliente"
.TxtApellido.SetFocus
Exit Sub
End If
If .TxtCel1.Value = "" Then
MsgBox "Digite el n° celular del cliente"
.TxtCel1.SetFocus
Exit Sub
End If
If .TxtDireccion.Value = "" Then
MsgBox "Digite la direccion del cliente"
.TxtDireccion.SetFocus
Exit Sub
End If
If .TxtLocalidad.Value = "" Then
MsgBox "Digite la localidad o ciudad del cliente"
.TxtLocalidad.SetFocus
Exit Sub
End If
If .TxtProvincia.Value = "" Then
MsgBox "Digite la provincia del cliente"
.TxtProvincia.SetFocus
Exit Sub
End If
If .TxtPuntoContac.Value = "" Then
MsgBox "Digite un punto de contacto"
.TxtPuntoContac.SetFocus
Exit Sub
End If
If .TxtRelacion.Value = "" Then
MsgBox "Digite que relacion tiene con el cliente"
.TxtRelacion.SetFocus
Exit Sub
End If
If .TxtCel2.Value = "" Then
MsgBox "Digite el n° de celular del punto de contacto"
.TxtCel2.SetFocus
Exit Sub
End If
End With
Dim Codigo As Variant
Dim ColCodigo As Range
Codigo = frmClientes.TxtIdCliente.Value
Set ColCodigo = Hoja3.ListObjects("Tab_Clientes").ListColumns(1).Range
Set CelEncontrada = ColCodigo.Find(what:=Codigo, After:=ColCodigo.Cells(1), LookAt:=xlPart)
If Not CelEncontrada Is Nothing Then
If MsgBox(" EL documento ya existe,¿quiere crearlo nuevamente?", vbYesNo) = vbNo Then
frmClientes.TxtIdCliente.SetFocus
Exit Sub
End If
End If
Set CelEncontrada = Hoja3.ListObjects("Tab_Clientes").ListRows.Add.Range.Cells(1)
Set CelEncontrada = Hoja3.ListObjects("Tab_Clientes").ListRows.Add.Range.Cells(1)
With frmClientes
CelEncontrada.Offset(0, 0).Value = .TxtIdCliente
CelEncontrada.Offset(0, 1).Value = .TxtNombre
CelEncontrada.Offset(0, 2).Value = .TxtApellido
CelEncontrada.Offset(0, 3).Value = .TxtCel1
CelEncontrada.Offset(0, 4).Value = .TxtTelFijo1
CelEncontrada.Offset(0, 5).Value = .TxtDireccion
CelEncontrada.Offset(0, 6).Value = .TxtLocalidad
CelEncontrada.Offset(0, 7).Value = .TxtProvincia
CelEncontrada.Offset(0, 8).Value = .TxtPuntoContac
CelEncontrada.Offset(0, 9).Value = .TxtRelacion
CelEncontrada.Offset(0, 10).Value = .TxtCel2
CelEncontrada.Offset(0, 11).Value = .TxtTelFijo2
End With
Set CelEncontrada = Nothing
Call ModClientes.LimpiarFormulario
MsgBox "CLIENTE REGISTRADO"
End Sub