Saber si es mayor de edad. VB 6.0
Disculpe la molestia. Resulta que tengo un inconveniente que no lo puedo resolver. Te comento: Quiero hacer un alta pero solo es posible si la persona a dar de alta es mayor de edad (18 años), además quiero verificar que las fechas ingresadas sean correctas, ejemplo: que la fecha de alta sea superior a la fecha de nacimiento, que la fecha de alta no sea superior al día de la fecha y por supuesto como dije anteriormente, que entre la fecha de ingreso y la de nacimiento hayan transcurrido 18 años. Tengo armado este código pero no me anda.
Private Sub cmdModificaVoluntario_Click()
Dim strFechaMaxNumVol As String
Dim rstFechaMaxNumVol As New ADODB.Recordset
Dim ActualizaVol As String
Dim rstvol As New ADODB.Recordset
Dim strVol As String
Dim rstActualizaVol As New ADODB.Recordset
Dim x As Integer
Dim FInscrip As Date
Dim Hoy As Date
Set rstActualizaVol = New ADODB.Recordset
For x = 0 To txtVoluntario.UBound
If txtVoluntario(x).Text = "" Then
MsgBox "Campo obligatorio.", vbInformation, "MODIFICACIÓN DE VOLUNTARIOS."
txtVoluntario(x).SetFocus
Exit Sub
End If
Next x
If DateDiff("Y", DTPFNac.Value, DTPFInscVol.Value) < 18 Then
MsgBox "Menor de edad. No se puede inscribir.", vbCritical, "COMPROBACIÓN EDAD VOLUNTARIO."
DTPFNac.SetFocus
'Limpiar_Text
Exit Sub
cmdModificaVoluntario.Enabled = False
End If
'VERIFICACIÓN INGRESO SUPERIOR A HOY
FInscrip = DTPFInscVol.Value
Hoy = Now
If FInscrip > Hoy Then
MsgBox "Ingrese una fecha inferior o igual a hoy.", vbCritical, "COMPROBACIÓN FECHA DE INGRESO VOLUNTARIOS."
DTPFInscVol.SetFocus
Exit Sub
End If
'FIN VERIFICACIÓN INGRESO SUPERIOR A HOY
'COMPROBAR QUE NO INGRESE UNA FECHA ANTERIOR AL NACIMIENTO
If DTPFInscVol.Value < DTPFNac.Value Then
MsgBox "Ingrese una fecha superior a la fecha de nacimiento", vbInformation, "COMPROBACIÓN DE FECHAS."
DTPFInscVol.SetFocus
Exit Sub
End If
'FIN COMPROBAR ANTERIOR AL NACIMIENTO
'VER SI FECHA INGRESO ES INFERIOR AL ÚLTIMO VOLUNTARIO ingresado
ActualizaVol = "Update Voluntarios SET ApeVol ='" & txtVoluntario(0).Text & "',NomVol='" & txtVoluntario(1).Text & "',FNacVol='" & DTPFNac.Value & "',FInscVol='" & DTPFInscVol.Value & "',TipoDocumento='" & txtVoluntario(2).Text & "',NumDocumento='" & txtVoluntario(3).Text & "',DomicilioParticular='" & txtVoluntario(4).Text & "',TelefonoParticular='" & txtVoluntario(5).Text & "',Celular='" & txtVoluntario(6).Text & "',Email='" & txtVoluntario(7).Text & "',Profesion='" & txtVoluntario(8).Text & "' Where NumVoluntario = " & txtBuscVoluntario.Text & ""
strFechaMaxNumVol = "SELECT * FROM VOLUNTARIOS WHERE NumVoluntario < " & txtBuscVoluntario.Text & " AND FInscVol > '" & DTPFInscVol.Value & "'"
Set rstFechaMaxNumVol = New ADODB.Recordset
rstFechaMaxNumVol.Open strFechaMaxNumVol, Base, adOpenStatic, adLockOptimistic
With rstFechaMaxNumVol
If .EOF And .BOF Then
Base.Execute (ActualizaVol)
Else
MsgBox "Ingrese una fecha de inscripción igual o superior a la fecha del último voluntario ingresado.", vbCritical, "VERIFICACIÓN FECHA DE ALTA VOLUNTARIOS."
DTPFInscVol_GotFocus
Exit Sub
End If
End WithMe lo ingresa igual Qué hago mal???
1 respuesta
Respuesta de Eduardo Saligari
1
