>Public Function IsValidUser() > Dim t_RecSet_user As Recordset, db As DAO.Database, qdf As DAO.Recordset, No_Recs As Integer > Dim QueryName As String > > QueryName = "User_Access" > > Set db = CurrentDb > 'Set qdf = db.OpenRecordset(QueryName) > 'qdf.MoveLast > > DoCmd.OpenQuery "user_access" > > 'No_Recs = DCount("*", "User_Access") > > 'No_Recs = qdf.RecordCount > > Set qdf = Nothing > Set db = Nothing > > ' Set t_RecSet_user = CurrentDb.OpenRecordset("select * from case_mgr where case_mgr.[casemgr_userid]='" & t_UserId & "';") > > > If No_Recs > 0 Then > 't_RecSet_user.MoveLast > IsValidUser = "Yes" > MsgBox "you are validated to access system" & " " & UCase(t_UserId) > Else > IsValidUser = "No" > MsgBox "you are not validated to access system" & " " & UCase(t_UserId) > End If > > 'Set t_RecSet_user = Nothing > >(returnusername) >End Function >When you say you're "getting error etc.", what error are you getting and on what line?