Click here to Skip to main content
15,945,119 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Ii've got a funtion UserLoginTime as below. The structure of my userlog table datatype varchar(50) for Username field and datatype datetime for Logintime field. Problem is the following line of code gives me an error at runtime "run-time error '13'. Type mismatch, " Any help where the problem could be. Am not very savvy in vb.

Function UserLoginTime(Username As String, LoginTime As Date) As Integer
If Rs.State = adStateOpen Then Rs.Close
    sql = " Select * From Userlog"
   Rs.Open sql, RSconn
    With Rs
        !Username = Username
        !LoginTime = LoginTime
   End With
   UserLoginTime = Rs(0).Value
Updated 12-Apr-13 7:13am
CHill60 12-Apr-13 13:13pm    
When you step through the code with the debugger which line is it precisely that is giving you the error?
Aleu Philip 12-Apr-13 13:15pm    
line 11 userLogintime = Rs(0).Value gives the error
CHill60 12-Apr-13 13:20pm    
Ok .. you've used Select * From Userlog. Try explicitly naming the columns you want returned instead of using "*" - obviously with the LoginTime as the first column :-)
Aleu Philip 12-Apr-13 13:26pm    
worked like a baby! thanks man.
Sergey Alexandrovich Kryukov 12-Apr-13 13:30pm    
I hope you understand why did I delete your "answer" which you even accepted formally. Why?

1 solution

You can't insert into Recordset until, you add new record!!!

See this:[^]
rstEmployees!firstname = strFirstName
rstEmployees!LastName = strLastName

But remember, you need to open Recordset[^] with adLockOptimistic LockType[^].
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900