lacampeona
Registered User.
- Local time
- Today, 07:31
- Joined
- Dec 28, 2015
- Messages
- 392
I have a small problem here you experts. I live in Europe and our date format is supposed to be ""04-07-2020"" for July 4th, 2020 and my code, no matter how I write it, is returning the format ""4. 07. 2020"". Here is an example of what I tried first:
and when I try to run that code, it breaks on "CurrentDb.Execute" giving me a syntax error. However, if I do what I think VBA wants me to do with hash marks, like this:
it gives me a different syntax error and the message shows the date variable as this: 4 .07. 2020
can anyone help me figure out what I am doing wrong? I have even tried putting Format(Date, "dd-mm-yyyy") in the actual SQL statement, and that fails too. Is it a regional setting that is the problem here? I have heard that this has been an issue for some users but I'm a little stuck. Please help. thanks.
Code:
Dim dtePwdDate As Date
If intPasswordExpireDays > 0 Then dtePwdDate = Format(Date, "dd-mm-yyyy")
If dtePwdDate <> 0 Then
CurrentDb.Execute "INSERT INTO tblUsers ( username, PWDDate )" & _
" SELECT '" & strUserName & "' AS UserName, " & " " & dtePwdDate & " AS PWDDate"
end if
Code:
If dtePwdDate <> 0 Then
CurrentDb.Execute "INSERT INTO tblUsers ( username, PWDDate )" & _
" SELECT '" & strUserName & "' AS UserName, #" & dtePwdDate & "# AS PWDDate"
end if
can anyone help me figure out what I am doing wrong? I have even tried putting Format(Date, "dd-mm-yyyy") in the actual SQL statement, and that fails too. Is it a regional setting that is the problem here? I have heard that this has been an issue for some users but I'm a little stuck. Please help. thanks.