Solved

creating accounts

Posted on 2002-04-22
5
155 Views
Last Modified: 2010-05-02
i have an application where it is password protected and connects to an MS Access DBase where there is a table in  it called "Users". Inside that table are the following fields.

Forename   Surname   Username    Password

each user can type in their username and password and logs into the program OK.

i would like to know how i can setup each persons account PASSWORD to expire in a certain amount of days and show on my form how many days are left before they have to change their password.
0
Comment
Question by:marksmall
  • 4
5 Comments
 
LVL 18

Expert Comment

by:bobbit31
Comment Utility
put a datefield called let's say "LastPwdChange".

Whenever you log-in, check this date against the current date using DateDiff ("d", Now(), rs.fields("LastPwdChange"))

if the result of Datediff is > number of days for expiration then prompt for change, otherwise show the result of datediff
0
 

Author Comment

by:marksmall
Comment Utility
can you provide a code example!
0
 
LVL 18

Expert Comment

by:bobbit31
Comment Utility
const DAYS_TILL_PASSWORD_EXPIRES = 14  '' 2 weeks for example

public sub login()

   Dim conn as new ADODB.Connection
   Dim rs as new ADODB.Recordset
   Dim strSQL as string
   Dim daysSinceChange as integer

   conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
              "Persist Security Info = False;" & _
              "Data Source=<your access db>"
   rs.open strSQL, conn, adOpenForwardOnly, adLockOptimistic

   if rs.EOF then
       msgbox "Incorrect User Name or Password"
   else
       daysSinceChange = DateDiff("d", Now(), rs.fields("LastPwdChange"))
       if daysSinceChange > DAYS_TILL_PASSWORD_EXPIRES then
            msgbox "you need to change your password"
            '' maybe open the form for doing so here
       else
            msgbox "you need to change your password in " & (DAYS_TILL_PASSWORD_EXPIRES - daysSinceChange)  
       end if        
   end if

   rs.close
   set rs = nothing
   conn.close
   set conn = nothing
     
end sub

0
 
LVL 18

Expert Comment

by:bobbit31
Comment Utility
oops, put rs.movefirst before the line "daysSinceChange = DateDiff(...)"
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 150 total points
Comment Utility
also probably want to pass the username and password to the login sub:
ie.
sub login(uName as string, pass as string)

'' also, strSQL should look something like
strSQL = "Select * from tblUsers where userName = '" & uName & "' and Password = '" & pass & "'"

end sub

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now