Date not changing in table

renenger

Registered User.
Local time
Today, 13:39
Joined
Oct 25, 2002
Messages
117
I have this code that a member helped me create in one of my forms. However, the date that is being input into the table is 30 Dec 99. It won't change no matter what the code is changed to.

The date is showing up correctly in the subform, it is just not inputting right into the table.

Private Sub Form_Open(Cancel As Integer)
Dim intNQ
intNQ = Nz(DMax("QuizNo", "tblQuizzes", "logon='" & Environ("Username") & "'"), 0) + 1

Me.subrmQuizzes.Form.Logon = Environ("Username")
Me.subrmQuizzes.Form.DATEControl = Format(Now(), "DD MMM YYYY")
Me.subrmQuizzes.Form.QuizNo = intNQ

CurrentDb.Execute "INSERT INTO tblQuizzes ( QUIZNO, [DATE], LOGON )SELECT " & intNQ & " , " & Format(Now(), "DD/MM/YYYY") & " , '" & Environ("Username") & "'"
End Sub

Any ideas?
 
What datatype is your field [date] set to in the table?

Peter
 
Date/Time no formatting.
 
You are passing it a text string, try
CurrentDb.Execute "INSERT INTO tblQuizzes ( QUIZNO, [DATE], LOGON )SELECT " & intNQ & " , " & Now() & " , '" & Environ("Username") & "'"
End Sub

HTH

Peter

Edited to add back an &
 
When I pasted

CurrentDb.Execute "INSERT INTO tblQuizzes ( QUIZNO, [DATE], LOGON )SELECT " & intNQ & " , " & Now() & " , '" & Environ("Username") & "'"

in I get Run Time error 3075: Syntax error (missing operator) in query expression '06/08/2005 10:59:19 AM'.
 
Ok. I changed it from NOW() to Date and it goes through with no problem. However, it still shows in the tbl as 30 Dec 99. I can't figure it out. It shows correctly in the unbound field on the subfrm. \


CurrentDb.Execute "INSERT INTO tblQuizzes ( QUIZNO, [DATE], LOGON )SELECT " & intNQ & " , " & Date & " , '" & Environ("Username") & "'" :mad:
 
Ok. I figured it out. Here is what I changed the code to in case anyone else has this same problem:

CurrentDb.Execute "INSERT INTO tblQuizzes ( QUIZNO, [DATE], LOGON )SELECT " & intNQ & " , " & Format$(Date, "yyyy-mm-dd") & ", '" & Environ("Username") & "'"
 
Ok. I Lied. I Thought That Did It But It Made It 1905 And Depending On How I Arrange The Mm/dd/yy, I Get All Different Dates.

I Could Really Use Some Help On This!!!
 
You're in Montana. The default US date format is Short Date (mm/dd/yyyy). The system expects to receive in that order and I expect that's why you're going the mysterious dates. Give it a try and see if it helps.

Bob
 
You have a field called DATE. This may have nothing to do with your current problem but it's a bad idea to use a reserved word as a name for a database object.
 
oops I forgot the date delimeters! :o

try

CurrentDb.Execute "INSERT INTO tblQuizzes ( QUIZNO, [DATE], LOGON )SELECT " & intNQ & " , #" & Now() & "# , '" & Environ("Username") & "'"

which wont work in the UK but should in the US :eek:

Peter
 

Users who are viewing this thread

Back
Top Bottom