Solved

creating accounts

Posted on 2002-04-22
5
159 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
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
VB6 Compile Compatibility Issue 4 116
vb6 connector to SQL Server 2 39
clicking a shape in a frame array vb6 3 47
Collapse and expand table in Word 2010 2 40
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

820 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