Solved

creating accounts

Posted on 2002-04-22
5
161 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 6961218
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
ID: 6962595
can you provide a code example!
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6963187
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
ID: 6963190
oops, put rs.movefirst before the line "daysSinceChange = DateDiff(...)"
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 150 total points
ID: 6963199
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

724 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