Neuigkeiten:

Ist euer Problem gelöst, dann bitte den Knopf "Thema gelöst" drücken!

Mobiles Hauptmenü

Datum mit SQL an Tabelle übergeben

Begonnen von Rivside, August 17, 2020, 08:40:40

⏪ vorheriges - nächstes ⏩

Rivside

Hallo!

Das Thema wurde öfters angesprochen sogar an externen Foren. Leider vorgeschlagene Lösungen im Internet zu finden, helfen mir nicht.

Ich versuche aus einem Formular ein Datensatzt per SQL und VBA an eine Tabelle zu übergeben. Leider, jedes Mal, kriege ich ne Fehlermeldung Datentypkonfilkt.

Ich habe schon mit CDbl und mit format versucht die Datum umzuwandeln, funktioniert leider nicht.

Die Felder sind als Datum festgelegt.

Hier mein Code:

    Dim sSQL As String
    Dim a, b As String

    a = Format(Me!Datum, "/#yyyy/-mm/-dd/#")
    b = Format(Me!Datum2, "/#yyyy/-mm/-dd/#")

    sSQL = "INSERT INTO test (Artikel, Datum, Datum2, Stückzahl) VALUES ('" & Me!Artikel & "', '" & a & "' , '" & b & "', " & Me!Stückzahl & ")"

    CurrentDb.Execute sSQL, dbFailOnError

DF6GL

Hallo,

die Hochkommata um die Datumswerte sind fehl am Platz:

Zitat.....  , " & a & " , " & b & ",   ....
Viele Grüße vom Bodensee
Franz, DF6GL

Hilfestellung:  http://www.access-o-mania.de/forum/index.php?topic=6969.msg118738#msg118738

Links und Tipps:
1.   http://v.hdm-stuttgart.de/~riekert/lehre/db-kelz/
1a. http://www.tinohempel.de/info/info/datenbank/normalisierung.htm
1b. https://support.office.com/de-de/article/Grundlagen-des-Datenbankentwurfs-eb2159cf-1e30-401a-8084-bd4f9c9ca1f5#bmterms
2.   http://www.donkarl.com
3.   https://web.archive.org/web/20201201233522/http://www.dbwiki.net/
4.   http://www.access-tutorial.de/
5.   http://www.tty1.net/smart-questions_de.htm
6.   http://access.joposol.com/accept

Last but not least:   < F1 > für Hilfe
;) Learning by doing not by spoon-feed ;)

Tipp: Find and Replace for Access

Rivside

Hallo,

sobald die Hochkommata weg, kriege ich folgende Fehlermeldung:

Syntaxfehler (fehlender Operator) in Abfrageausdruck '.#2020.-08.-17#'

DF6GL

Hallo,

dann ändere zusätzlich:


Zitata = Format(Cdate(Me!Datum), "/#yyyy/-mm/-dd/#")
b = Format(Cdate(Me!Datum2), "/#yyyy/-mm/-dd/#")
Viele Grüße vom Bodensee
Franz, DF6GL

Hilfestellung:  http://www.access-o-mania.de/forum/index.php?topic=6969.msg118738#msg118738

Links und Tipps:
1.   http://v.hdm-stuttgart.de/~riekert/lehre/db-kelz/
1a. http://www.tinohempel.de/info/info/datenbank/normalisierung.htm
1b. https://support.office.com/de-de/article/Grundlagen-des-Datenbankentwurfs-eb2159cf-1e30-401a-8084-bd4f9c9ca1f5#bmterms
2.   http://www.donkarl.com
3.   https://web.archive.org/web/20201201233522/http://www.dbwiki.net/
4.   http://www.access-tutorial.de/
5.   http://www.tty1.net/smart-questions_de.htm
6.   http://access.joposol.com/accept

Last but not least:   < F1 > für Hilfe
;) Learning by doing not by spoon-feed ;)

Tipp: Find and Replace for Access

PhilS

Zitat von: Rivside am August 17, 2020, 08:40:40    a = Format(Me!Datum, "/#yyyy/-mm/-dd/#")
    b = Format(Me!Datum2, "/#yyyy/-mm/-dd/#")
Der Format-Ausdruck ist nicht richtig. Du muss den Backslash verwenden um die Trennzeichen zu escapen.

Format(Me!Datum, "\#yyyy\-mm\-dd\#")

Als generellen Tipp empfehle ich mein VBA-SQL-String-Tutorial.
Neue Videoserie: Windows API in VBA

Klassische CommandBars visuell bearbeiten: Access DevTools CommandBar Editor

DF6GL

Oh je.... meine Brille funktioniert auch nicht mehr richtig....   :o  :'(

Sowas aber auch...
Viele Grüße vom Bodensee
Franz, DF6GL

Hilfestellung:  http://www.access-o-mania.de/forum/index.php?topic=6969.msg118738#msg118738

Links und Tipps:
1.   http://v.hdm-stuttgart.de/~riekert/lehre/db-kelz/
1a. http://www.tinohempel.de/info/info/datenbank/normalisierung.htm
1b. https://support.office.com/de-de/article/Grundlagen-des-Datenbankentwurfs-eb2159cf-1e30-401a-8084-bd4f9c9ca1f5#bmterms
2.   http://www.donkarl.com
3.   https://web.archive.org/web/20201201233522/http://www.dbwiki.net/
4.   http://www.access-tutorial.de/
5.   http://www.tty1.net/smart-questions_de.htm
6.   http://access.joposol.com/accept

Last but not least:   < F1 > für Hilfe
;) Learning by doing not by spoon-feed ;)

Tipp: Find and Replace for Access