Fecha VB6 y SQL
Hola! Estoy en VB6 y access 2003 y quiero grabar en la BD los registros, me graba todos los registros BIEN, menos el de fecha, me graba cualquier fecha no la que tengo escrita en el text box... Por ejemplo pongo 12/12/2009 y cdo veo en la BD se grabo 22/01/1900 o se graba el año 1989. Para grabar uso esto... (es la fecha de una compra, tabla compra)
consultaSQL "INSERT INTO compra (fecha) values Val (txtfecha.text)"
Tendra algo q ver con esto......?
Private Sub txtFecha_LostFocus()
Dim dato
If IsDate(txtFecha.Text) Then
dato = CDate(txtFecha.Text)
If Val(Year(txtFecha.Text)) < 1900 Or Val(Year(txtFecha.Text)) > 2009 Then
MsgBox "ingreso mal el año", vbCritical, "Error"
txtFecha.Text = ""
End If
Else: MsgBox "verifique la fecha.. Dd/mm/aaaa", vbExclamation, "Atencion"
txtFecha.SetFocus
txtFecha.Text = ""
End If
End Sub
consultaSQL "INSERT INTO compra (fecha) values Val (txtfecha.text)"
Tendra algo q ver con esto......?
Private Sub txtFecha_LostFocus()
Dim dato
If IsDate(txtFecha.Text) Then
dato = CDate(txtFecha.Text)
If Val(Year(txtFecha.Text)) < 1900 Or Val(Year(txtFecha.Text)) > 2009 Then
MsgBox "ingreso mal el año", vbCritical, "Error"
txtFecha.Text = ""
End If
Else: MsgBox "verifique la fecha.. Dd/mm/aaaa", vbExclamation, "Atencion"
txtFecha.SetFocus
txtFecha.Text = ""
End If
End Sub
1 respuesta
Respuesta de Roberto Alvarado
1
