Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Access 2000, VBA, Datum in Variable

Empfohlene Antworten

Veröffentlicht

Hi, Leute!

Problem:

Access versteht nicht den Vergleich im WHERE-Abschnitt folgender Recordset-Zuweisung:

Function XYZ(strAufgabe As String, datErfassungsDatum As Date) As String

Dim recAufgKennzi As DAO.Recordset

Set recAufgKennzi = CurrentDb().OpenRecordset("" & _

"SELECT " & _

"id_x_Aufgabe, " & _

"x_Datum_Von, " & _

"x_Datum_Bis, " & _

"x_Kennziffer " & _

"FROM " & _

"tbl_Aufgaben_Kennziffern_Zeitraum " & _

"WHERE " & _

"id_x_Aufgabe='" & strAufgabe & "' " & _

"AND x_Datum_Von<=#" & datErfassungsDatum & "# " & _

"AND " & _

"(x_Datum_Bis>=#" & datErfassungsDatum & "# " & _

"OR x_Datum_Bis Is Null)" & _

";")

...

End Function

Es kommt dann die Fehlermeldung: "Fehler in Datum in Abfrageausdruck...".

Und dort erscheint im zusammengesetzten Ausschnitt des WHERE-Abschnitts das korrekte Datum. (Am unlogischen Datumsaufbau "Monat, Tag, Jahr" liegt es nicht. Derentsprechende Verweis auf die "dao360.dll" ist gelegt. Und mit einem festen Datum funktioniert die Abfrage auch.)

(Ich versuche gleich, das Datum als Text zu formatieren in der Form "20/04/2004". Vielleicht hilft das!?)

  • Autor

Hi, Leute!

Ich habe mir eine kleine Funktion gestrickt, die mir ein Datum in SQL-taugliche Schreibweise umformt:

Function fktSqlDatum(datDatum As Date) As String

fktSqlDatum = Format(Day(datDatum), "00") & "/" & Format(Month(datDatum), "00") & "/" & Format(Year(datDatum), "0000")

End Function

Es ist vielleicht nicht die eleganteste Lösung, funktioniert aber.

Innerhalb meines SQL-Ausdrucks schicke ich das Datum durch diese funktion und setzte dadurch einen tauglichen Text ein.

Danke und kann zu!

Oder in der Art:

"SELECT ... WHERE (DATUM = #" & Format(myDate, "mm\/dd\/yyyy hh:mm:ss") + "#)"

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.