I need some help with this code which i cant get over for many hours now.
Im making a db used for ducment handling and here i need a date for the newly uploaded document.
If MsgBox("Mai dátummal mehet?", vbYesNo, "Verzió") = vbYes Then
db.Execute ("UPDATE Dokumentumok SET Verzió = Date() WHERE Jelölés='" & Me.Jelölés & "'")
Else
version = InputBox("Add meg a dátumot éééé.hh.nn.", "Verzió", Date)
version = Replace(version, ".", ". ")
If IsDate(version) Then
db.Execute ("UPDATE Dokumentumok SET Verzió ='" & CDate(version) & "' WHERE Jelölés='" & Me.Jelölés & "'")
Else
MsgBox "Rossz formátum, mentve mai dátummal"
db.Execute ("UPDATE Dokumentumok SET Verzió = Date() WHERE Jelölés='" & Me.Jelölés & "'")
End If
End If
First msgbox asks if it goes with todays date, if yes, then it updates the specific date which works just fine. If not, inputbox asks for the date. I live in Hungary, defualt date format is YYYY.MM.DD. here, in access by default it is YYYY. MM. DD. - there is space between them, dont know if it matters
So far i have tried to input with the following formats with lets say October 20, 2015:
- 2015.10.20.
- 20.
- 10.20.2015
- 2015
- 20.10.2015
- 2015
- 10/20/2015
- 20/10/2015
Even trying with a small code in a module with everything set to manual to update that date field in the table, through isdate() check Every type passed date check but still either code runs and date field remains empty or i get error Too few parameters, expected 1 if i try sate with "\" instead of "."
version = "2015.10.20."
version = Mid(version, 6, 6) & Left(version, 4)
version = Replace(version, ".", "/")
If IsDate(version) Then
db.Execute ("UPDATE Dokumentumok SET Verzió = #" & version & "# WHERE Jelölés=E2")
End If
This one gives error missing operator in query expression '2015. 10. 20.'
version = "2015. 10. 20. "
If IsDate(CDate(version)) Then
db.Execute ("UPDATE Dokumentumok SET Verzió = " & CDate(version) & " WHERE Jelölés=E2")
End If
This one syntax error in date in query expression '#2015. 10. 20.'
db.Execute ("UPDATE Dokumentumok SET Verzió = #" & CDate(version) & "# WHERE Jelölés=E2")
I have tried many combinations of variable between '' or ##, values between '', ##, date variables, formatted string variables etc.
Guys, I cant seem to make it work on my own I need an help with it.
Thanks in advance, Kristof
dim version as date? and cant you useformat ()to change the date?