Click here to Skip to main content
13,052,696 members (67,670 online)
Rate this:
Please Sign up or sign in to 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
Posted 12-Apr-13 7:09am
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?
Aleu Philip 12-Apr-13 13:32pm
I dont..would be pleased to

well i not the author..thanks man.
Sergey Alexandrovich Kryukov 12-Apr-13 15:34pm
Sorry for possible miscommunication…
ThePhantomUpvoter 12-Apr-13 13:28pm
You are trying to return a datetime from your function as an integer.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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[^].

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 12 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100