Datumswert
31.12.2003 16:15:48
Michael Beckhove
Private Sub txtNORDAT1_Change()
'Start für Datum prüfen
Dim sTxt As String
If txtNORDAT1.Text = "" Then Exit Sub
sTxt = txtNORDAT1.Text
If Right(sTxt, 1) Like "[!0-9]" Then
txtNORDAT1.Text = Left(sTxt, Len(sTxt) - 1)
Exit Sub
End If
If IsNumeric(sTxt) = False Then GoTo ERRORHANDLER
If Len(sTxt) = 6 Then
sTxt = Left(sTxt, 2) & "." & Mid(sTxt, 3, 2) _
& "." & Right(sTxt, 2)
If Not IsDate(sTxt) Then
GoTo ERRORHANDLER
Else
txtNORDAT1.Text = sTxt
Exit Sub
End If
End If
'Select der Daten entsprechend WKZ
Worksheets("Bereichsnamen").Range("NORDAT1_PKW").Value = txtNORDAT1.Text
Exit Sub
ERRORHANDLER:
Beep
MsgBox "Kein Datum!"
txtNORDAT1.Text = ""
txtNORDAT1.SetFocus
'Ende Datum prüfen
End Sub
Jetzt zu meinem Problem. Das Datum wird als Text in die Zelle NORDAT1_PKW übernommen. Ich muss aber mit diesem Wert als Datumswert eine Abfrage verbinden.
Wie muss ich den o.a. Code verändern ?
Danke sagt
Michael
PS. Einen Dank auch an herber.de. Die CD ist super, den der erste Teil des Code
ist aus dieser CD.