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!
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