Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / May 2005

Tip: Looking for answers? Try searching our database.

Need Login To Auto Populate Userid Field on Form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Billy Norris - 03 May 2005 19:43 GMT
I have a password routine that works.  I have a table of Userid, UserName,
User password.

The password if successful will open an edit form.  How can I get the edit
form to populate with the User id from the password routine.  Below is my
password code:

Private Sub Submit_Click()
'Simple password routine.

   Dim F As Form
   Set F = Forms![frmPswrdEdit]
   
   If F!pwd = "awesome" Then GoTo pwd_success
   
   If F!pwd <> "awesome" Then GoTo pwd_invalid
   If IsNull(F!pwd) Then GoTo pwd_invalid
   If Len(F!pwd) = 0 Then GoTo pwd_invalid
   
   On Error GoTo pwd_trap

pwd_success:
   DoCmd.Close acForm, "frmpswrdEdit"
   acMenuVer70

   DoCmd.OpenForm "frmEdit"
' The following Me!fields are located on the "frmEdit"
    Me!DateUpdated = Date
    Me!TimeUpdated = Time()
    Me!Admin = tbl.Users "Name" 'get User name from User table
   Exit Sub
Klatuu - 03 May 2005 21:11 GMT
Billy,

There are a number of issues here.  First, you say you have a Users table,
but then your password is hard coded as "awesome".  How do you know which
user is trying to log in?  Next, GET RID OF THE GOTOs!!!!!!  The most glaring
problem here is that your pwd_invalid tag is not in your sub.  That is the
worst thing you can do with a goto.  Whenever you jump outside the sub you
are in, it will stay resident.  You can blow memory with this situation.  
Better form would be:

Private Sub Submit_Click()
'Simple password routine.
Dim F As Form
Dim blnDone as Boolean

   Set F = Forms![frmPswrdEdit]
   do until blnDone    
       If F!pwd = "awesome" Then
'Here is where you should find the user who is logged in.  I  can't give you
a solution because I don't know how you know who is logged in.
           acMenuVer70
           DoCmd.OpenForm "frmEdit"
' The following Me!fields are located on the "frmEdit"
           Me!DateUpdated = Date
           Me!TimeUpdated = Time()
           blnDone = True
       Else
           If msgbox("Retry or Cancel",vbRetryCancel,"Invalid Password") _
                   = vbCancel Then
               blnDone = True
           End If
   Loop
   DoCmd.Close acForm, "frmpswrdEdit"
Exit Sub

Note that your checks on the password text box for zero length and null are
omitted.  They are unnecessary.

> I have a password routine that works.  I have a table of Userid, UserName,
> User password.
[quoted text clipped - 27 lines]
>      Me!Admin = tbl.Users "Name" 'get User name from User table
>     Exit Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.