Data type mismatch

Spocks

New member
Local time
Today, 22:02
Joined
Aug 25, 2013
Messages
9
Hi all! I've been working on a part of my database in which the entrance and exit time of a persons attendance at a gym is recorded. For some reason i get the data type mismatch error for logging out. I don't know whats happening as the log in part of the code works fine and the fields in the table are date/time data types.The code is below:

Select Case Me.cboStatus.Value

Case Is = "Login"
DoCmd.RunSQL "INSERT INTO Gym_Attendance ([Student ID], [Gym Date], [Entrance Time]) VALUES ( '" & Me.txtStudentID.Value & "', Date(), Time())"
MsgBox "Login Successful"
Me.txtStudentID.Value = ""

Case Else
DoCmd.RunSQL "UPDATE Gym_Attendance SET [Exit Time] = Time() WHERE [Student ID] = ( '" & Me.txtStudentID.Value & "') AND [Gym Date] = Date()"
MsgBox "Logout Successful"
Me.txtStudentID.Value = ""
End Select
 
If the ID field is numeric you don't want the single quotes around the value.
 
Thank you Paul! I'm just curious, why does it work with the login part of the code with the textbox with single quotes?
 
No problem! To be honest I would expect both to fail, but perhaps it's less sensitive to it in the VALUES clause.
 

Users who are viewing this thread

Back
Top Bottom