Access-o-Mania

Access-Forum (Deutsch/German) => Formular => Thema gestartet von: soylatino am Oktober 04, 2018, 02:23:16

Titel: Laufzeitfehler - Syntaxis in Datum in Abfrageausdruck
Beitrag von: soylatino am Oktober 04, 2018, 02:23:16
Hallo liebes Forum,

ich hoffe ihr könnt mir dabei helfen. Ich versuche herauszufinden, warum erscheint immer eine Fehlermeldung wenn ich mein Formular starte:

Die Fehlermeldung lautet:
Microsoft VIsual Basic
Laufzeitfehler "3075"

Syntaxfehler in Datum in Abfrageausdruck "[Attdate] = #04.10.2018"

Der Code:
Private Sub Form_Load()
Dim AddToday As String
DoCmd.ShowToolbar "Ribbon", acToolbarNo
Me.cmdOldClass.Caption = "Old Classes"
Me.ListClass.RowSource = "select * from qryClasslist where currentActive = true"

If IsNull(DLookup("Date_ID", "tblAttDate", "[Attdate] = #" & Date & "#")) Then

        'MsgBox "is null"
        'add today date to AttDate table
        AddToday = "Insert INTO tblAttDate(AttDate) Select Date() as myTodayDate;"
                'MsgBox (AddToday)
                DoCmd.SetWarnings False
                DoCmd.RunSQL AddToday
                DoCmd.SetWarnings True
Else
    'MsgBox "is not null" ' Do nothing
End If
End Sub



Danke im voraus!
Titel: Re: Laufzeitfehler - Syntaxis in Datum in Abfrageausdruck
Beitrag von: DF6GL am Oktober 04, 2018, 08:40:23
Hallo,


SQL erfordert ISO- oder US-Datumsformat

If IsNull(DLookup("Date_ID", "tblAttDate", "[Attdate] = " & Format(Date,"\#yyyy-mm-dd\#") ) )Then

oder gleich die Date-Funktion als Teil der Where-Condition einsetzen:
If IsNull(DLookup("Date_ID", "tblAttDate", "[Attdate] = Date()")) Then