Page 1 of 3 123 LastLast
Results 1 to 15 of 41
  1. #1
    Join Date
    Aug 2006
    Posts
    559

    Unanswered: OpenArgs ? Maybe? Not?

    I have the following code on an "OnOpen" event of a switchboard form. The code works ok, however it continually runs each time a user clicks on any "Main Menu" command button.

    Code:
    Private Sub Form_Open(Cancel As Integer)
    If isAdmin = True Then
        MsgBox "Recognize AccessID = 1..."
        Me.cmdAdminMenu.Visible = True
    Else
        Me.cmdAdminMenu.Visible = False
    End If
    
    'Run query, qryReminder, to see if there are any overdue tasks within the database that are NOT closed.
    'Send a message box prompting the user if they would like to see the overdue tasks, if any (via Yes / No)
    'Select "Yes", opens frmReminders with query ran for user to select option
    'Select "No", opens frmMainMenu
    
    Dim lngCount As Long
    
    lngCount = Nz(DCount("DaysSinceOriginated", "qryReminder"), 0)
    
    If lngCount > 0 Then
    
      Select Case MsgBox("There are " & lngCount & " overdue tasks. Would you Would you like to view the overdue tasks?", vbYesNo + vbExclamation)
      
      Case vbYes
        
        DoCmd.Close acForm, "frmMainMenu" 'closes frmMainMenu form if the user selects "Yes" to view the reminders
        DoCmd.OpenForm "frmReminders"
            
        Case vbNo
        
        DoCmd.OpenForm "frmMainMenu"
    
    End Select
    
    End If
      
    End Sub
    I'm thinking about trying an "OpenArgs" statement to make it run only on the INITIAL LOGIN of the user into the database but I can't for the life of me figure out how.

    I am thinking ( I know it's bad, we all know this), it should be some thing like this, however not in the wording that I use:

    If user comes from 'frmLogon', then run reminder query. If user not from LogonForm, then no run reminder query.

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Are you calling Form_Open again anywhere in the form? Are you also opening the form again?
    i.e...
    Case vbNo

    DoCmd.OpenForm "frmMainMenu"

    If you're opening the form again in your code for frmMainMenu, it will execute the Form_Open again.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Aug 2006
    Posts
    559
    Not that I know of.

    Like if the user selects "Yes", it'll open the form for Reminders. There they will make a selection (only to print reports) and then there is a command button for "Main Menu". When they select that, it opens the form MainMenu and runs the 'on open' event all over again so that the user can only get out of it by selecting "no".

    in the Select Case statement, when the user selects "No", they are brought right to the main menu form.

    Regardless of the user selecting any other "Main Menu" command buttons, it always runs that "onopen" event. I'm trying to make it so that it only runs if the user comes from the Logon form and nothing else.

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    You can also throw in a msgbox("OnOpen") in the OnOpen event and see to make sure it's actually running the OnOpen event again. It shouldn't happen when you click on a button on the frmMainMenu (isn't that your "Main Menu" form) unless something wierd is going on.

    Also maybe do a search (everywhere) in the code for "frmMainMenu".
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    Aug 2006
    Posts
    559
    Quote Originally Posted by pkstormy
    You can also throw in a msgbox("OnOpen") in the OnOpen event and see to make sure it's actually running the OnOpen event again. It shouldn't happen when you click on a button on the frmMainMenu (isn't that your "Main Menu" form) unless something wierd is going on.

    Also maybe do a search (everywhere) in the code for "frmMainMenu".

    Ok, you just lost me. I'm going to upload the db here so that everyone can see what my issue is.

    splash screen -->
    Logon screen -->

    Message box "Display overdue"
    -yes, takes you to frmReminders .
    -no, takes you to frmMainMenu

    **If you click on "yes", display the reminders, then click "main menu" button, it'll run the query and ask you if you want to display the reminders.

    ***It does it also if you click on any of the command buttons on the main menu, then select "main menu" from that form.
    Attached Files Attached Files

  6. #6
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    It seems to me like this code....
    Dim lngCount As Long

    lngCount = Nz(DCount("DaysSinceOriginated", "qryReminder"), 0)

    If lngCount > 0 Then

    Select Case MsgBox("There are " & lngCount & " overdue tasks. Would you Would you like to view the overdue tasks?", vbYesNo + vbExclamation)

    Case vbYes

    DoCmd.Close acForm, "frmMainMenu" 'closes frmMainMenu form if the user selects "Yes" to view the reminders
    DoCmd.OpenForm "frmReminders"

    Case vbNo

    DoCmd.OpenForm "frmMainMenu"

    End Select

    End If

    Should be somewhere in the frmUserLogon because it's doing exactly what you asked it to...it's checking for reminders every time you open frmMainMenu (if that's what you want it to do.) Is that what the issue is - i.e. the reminder question which keeps appearing every time you open the frmMainMenu or did I read you wrong? You'll notice that every time the Main Menu is closed and reopened, it asks you this question. If the Main Menu is not closed, it doesn't ask the question.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  7. #7
    Join Date
    Aug 2006
    Posts
    559
    yes sir, you're right.

    I think it's gotta be put in the "onclose" event of the frmLogon.

    Then I guess I'll have to move that code to verify user level to the "onopen" of the frmMainMenu? We'll test and see if that'll work.


    *********EDIT**********

    Ok, tried moving to the "onclose" of the logon form. It works but then it also opens the main menu form and I'm going to jump in and assume it's cause the command button is "open form, frmMainMenu". So i'm going to take the code I just put in the "onclose" event and put it in the "cmdOk" button instead. That way, if the user goes to log into the db, it'll ask them if they want to open the reminders, if not, it'll go on to the main menu. Otherwise they'll open the main menu. I am going to assume that I'll also have to take the "verify user level" and put it in the "onopen" event of "frmMainMenu".


    !!!! this is me going out on a limb here so bear with me...
    Last edited by Grafixx01; 06-04-07 at 17:59.

  8. #8
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    If I read you correctly and interpreted what you're trying to do which is set a reminder flag true or false FOR THAT DAY when the user get's into the database. If this is so you need to add a field to your tblUsers table. You would add: RemindDate (datatype = date). Then on your frmUserLogon (which is where I'd put it) unless you want to have the checking event fire every time they open the Main Menu (which I personally would not do). But your code would look like this:

    Dim RemindMeDate as date
    RemindMeDate = Nz(DLookup("[RemindDate]", "[tblUsers]", "[User_Name] = '" & fOSUserName() & "'"), 0)
    if RemindMeDate < Date() then
    Dim lngCount As Long

    lngCount = Nz(DCount("DaysSinceOriginated", "qryReminder"), 0)

    If lngCount > 0 Then

    Select Case MsgBox("There are " & lngCount & " overdue tasks. Would you Would you like to view the overdue tasks?", vbYesNo + vbExclamation)

    Case vbYes

    DoCmd.Close acForm, "frmMainMenu" 'closes frmMainMenu form if the user selects "Yes" to view the reminders
    DoCmd.OpenForm "frmReminders"

    Case vbNo
    Call SetReminderNo
    DoCmd.OpenForm "frmMainMenu"

    End Select

    End If
    End If

    Function SetReminderNo()
    'This sets the RemindDate to today's date so the reminder message doesn't keep appearing FOR TODAY but will reappear tomorrow.
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Dim strSQL As String
    strSQL = "Select * from tblUsers where User_Name = '" & fOSUserName() & "'"
    rs.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
    rs!RemindDate = date()
    rs.update
    rs.close
    set rs = nothing
    end function

    But again, I would put this code and the function in the frmUserLogon, not the frmMainMenu. Otherwise, if the user selects Yes, it will continuely ask them the question again when the frmMainMenu is opened every time.
    Last edited by pkstormy; 06-04-07 at 18:04.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  9. #9
    Join Date
    Aug 2006
    Posts
    559
    Hey now Paul, I didn't know you can do that! Cool stuff.

    Now if I put that in the "cmdOk" button, where the user first enters their user name and password, where do you think it would go in the code below to still verify the user name and password?

    **Asking because I've tried to edit this code and messed up the DB a great deal so I don't want to mess with it really by trial-and-error on my part** (not trying to be babied through it but yeah, it's just complex for me to decipher.

    Code:
    Private Sub cmdOk_Click()
    If isPasswordOK(Me!txtPassword) = True Then
        DoCmd.Close acForm, "frmUserLogon"
        DoCmd.OpenForm "frmMainMenu"
    Else
      
        ' MsgBox "Password incorrect....try again."
        ' Modify this with your code below
    'End If
    'Exit Sub
    
    On Error GoTo Err_cmdOk_Click
    '-----------------------------------------------------------------------------------------------------------------------------
    ' This code is used to validate users found in the tblSecurity table. If the wrong user name or password is
    ' provided access is denied.
    ' Created by: Richard Rensel
    ' Date Created: 18 Feb 2002
    ' Modified by Nick Phillips
    ' MODIFICATIONS: If Wrong Name/password is entered, then the NT login name is grabbed and updated to tblFailedAttempts
    ' Also if the wrong password is entered three times the Login is disabled until it is unlocked by an Admin
    ' This will now check to see if the person is denied access, and if they are the DB is closed, and also if their
    ' password has been reset they are forced to change their password once they enter in the random reset password
    ' Date Modified: 19 feb 2002
    '-----------------------------------------------------------------------------------------------------------------------------
        Dim db As DAO.Database
        Dim rst As DAO.Recordset
        Dim rst1 As DAO.Recordset
        Dim rstV As Recordset
        Dim stDocName As String
        Dim stLinkCriteria As String
        
        Set db = CurrentDb()
        Set rst = db.OpenRecordset("tblSecurity", dbOpenDynaset)
        
        If Not IsNull(Me.txtUser) And Not IsNull(Me.txtPassword) Then
            rst.FindFirst "Password = '" & Me.txtPassword & "'" & " And UserID = '" & Me.txtUser & "'"
        
        '----------------------------------------
        'If their is a problem logging in the NT username is grabbed and appended to tblFailedAttempts. The reason
        'I chose the NT login in name vs. the UserID, is because many times people will browse a network and find
        'A database and start trying to break-in. This way you can get them the first time they enter a wrong name/PW
        'This WILL NOT let you know if a valid user is attempting to log-in while signed onto a computer under another
        'NT log-in name
        
                If rst.NoMatch Then
                Set rst1 = db.OpenRecordset("tblFailedAttempts", dbOpenDynaset)
                With rst1
                    .AddNew
                    ![computer_login] = Me.txtUser_hidden
                    .Update
                End With
                MsgBox "You entered the wrong User Name or Password." & Chr(13) & _
                "Please enter the correct User Name and Password or " & Chr(13) & _
                "contact the Database Adminstrator for assistance.", vbOKOnly + vbCritical, "Logon Denied"
        'This counts how many times a user has typed in the wrong UserID/Password combo. After three attempts the user is
        'suspended from the DB, and cannot get access until their account is reset by the Admin
        
                cnt = cnt + 1 'increment counter if wrong password entered
                If cnt = 3 Then  'Set up number of tries
                    'Display Message Box
                    MsgBox "Access Violation Program Will Now Close", , "Violation Detected"
                    DoCmd.OpenForm "frmPWChangeCheck", , , , , acHidden
                    [Forms]![frmPWChangeCheck]![Active] = False
                    DoCmd.Quit 'quit application and close Access
                End If
    
                ElseIf Me.txtPassword = "password" Then
    JumpIn:
    
    
                MsgBox "This is the first time using the database or your password has been reset." & Chr(13) & _
                "You must change your password before you can enter the database.", _
                vbOKOnly + vbExclamation, "Change Password"
                
    JumpIn1:
                stDocName = "frmUserLogonNew"
                stLinkCriteria = "[UserID]=" & "'" & Me![txtUser] & "'"
                DoCmd.OpenForm stDocName, , , stLinkCriteria
            Else
                'This opens another hidden form, that has two values on it... PWChange, and Active. If the active check box
                'is blank, then the user is denied access to the database. This value gets set to "NEW" When a users password
                'is reset from the Admin Users form. This next if/then statement checks to see if the word "NEW" is there
                'and if it is, then it forces the user to change it by going back above with the JumpIn: statement!!
                
                DoCmd.OpenForm "frmPWChangeCheck", , , , , acHidden
                
                    If [Forms]![frmPWChangeCheck]![Active] = False Then
                        MsgBox "Your Database privileges have been revoked" & Chr(13) & _
                        "Please contact the Database Administrator for assistance", vbOKOnly + vbCritical, "Logon Denied"
                        DoCmd.Quit
                    Else
                        If [Forms]![frmPWChangeCheck]![PWChange] = "New" Then
                                GoTo JumpIn:
                        Else
                   
                        
                        
    '############This is the password DATE validation code #############
                        
        DoCmd.OpenForm "frmPasswordHistory", , , , , acHidden
                        
        Select Case Forms!frmPasswordHistory.DaysOld
    
        Case -50
            If vbYes = MsgBox("10 days before your password expires. Want to change it now?", vbYesNo Or vbExclamation, "Password?") Then
                DoCmd.Close acForm, "frmPasswordHistory"
                GoTo JumpIn1:
            End If
        Case -51
            If vbYes = MsgBox("9 days before your password expires. Want to change it now?", vbYesNo Or vbExclamation, "Password?") Then
                DoCmd.Close acForm, "frmPasswordHistory"
                GoTo JumpIn1:
            End If
        Case -52
            If vbYes = MsgBox("8 days before your password expires. Want to change it now?", vbYesNo Or vbExclamation, "Password?") Then
                DoCmd.Close acForm, "frmPasswordHistory"
                GoTo JumpIn1:
            End If
        Case -53
            If vbYes = MsgBox("7 days before your password expires. Want to change it now?", vbYesNo Or vbExclamation, "Password?") Then
                DoCmd.Close acForm, "frmPasswordHistory"
                GoTo JumpIn1:
            End If
        Case -54
            If vbYes = MsgBox("6 days before your password expires. Want to change it now?", vbYesNo Or vbExclamation, "Password?") Then
                DoCmd.Close acForm, "frmPasswordHistory"
                GoTo JumpIn1:
            End If
        Case -55
            If vbYes = MsgBox("5 days before your password expires. Want to change it now?", vbYesNo Or vbExclamation, "Password?") Then
                DoCmd.Close acForm, "frmPasswordHistory"
                GoTo JumpIn1:
            End If
        Case -56
            If vbYes = MsgBox("4 days before your password expires. Want to change it now?", vbYesNo Or vbExclamation, "Password?") Then
                DoCmd.Close acForm, "frmPasswordHistory"
                GoTo JumpIn1:
            End If
        Case -57
            If vbYes = MsgBox("3 days before your password expires. Want to change it now?", vbYesNo Or vbExclamation, "Password?") Then
                DoCmd.Close acForm, "frmPasswordHistory"
                GoTo JumpIn1:
            End If
        Case -58
            If vbYes = MsgBox("2 days before your password expires. Want to change it now?", vbYesNo Or vbExclamation, "Password?") Then
                DoCmd.Close acForm, "frmPasswordHistory"
                GoTo JumpIn1:
            End If
        Case -59
            If vbYes = MsgBox("1 day before your password expires. Want to change it now?", vbYesNo Or vbExclamation, "Password?") Then
                DoCmd.Close acForm, "frmPasswordHistory"
                GoTo JumpIn1:
            End If
        Case -60
                MsgBox "Your password Has expired.You must change it before you can Log In", vbOKOnly + vbCritical, "Invalid Password"
                DoCmd.Close acForm, "frmPasswordHistory"
                GoTo JumpIn1:
        Case Is < -60
                MsgBox "Your password Has expired.You must change it before you can Log In", vbOKOnly + vbCritical, "Invalid Password"
                DoCmd.Close acForm, "frmPasswordHistory"
                GoTo JumpIn1:
        Case Else
            ' user is fine - do nothing
    End Select
                
    '############# END PASSWORD DATE VALIDATION CODE##################
                        
                                DoCmd.Close acForm, "frmUserLogon", acSaveNo 'close the frmUserLogon screen
                                stDocName = "frmMainMenu" 'open frmMainMenu upon correct login being entered
                                DoCmd.OpenForm stDocName, , , stLinkCriteria
                        End If
                    End If
            End If
        Else
            MsgBox "You left the User Name and/or Password blank." & Chr(13) & _
            "Please enter the correct User Name and Password or " & Chr(13) & _
            "contact the Database Adminstrator for assistance.", vbOKOnly + vbCritical, "Logon Denied"
        End If
        
        With User
            .AccessID = rst.Fields("AccessID")
            .ViewID = rst.Fields("ViewID")
            .Active = rst.Fields("Active")
            .Password = rst.Fields("Password")
            .SecurityID = rst.Fields("SecurityID")
            .UserID = rst.Fields("UserID")
        End With
        
        rst.Close
        
    Exit_cmdOk_Click:
        Exit Sub
    
    
    Err_cmdOk_Click:
        MsgBox Err.Description
        Resume Exit_cmdOk_Click
    End If 'I added
    
    End Sub

  10. #10
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Ouch...I looked at this code this last weekend and I didn't really like it because it does a lot of stuff (including opening hidden forms) while the recordset is open (i.e. rst and rst1). Give me a bit.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  11. #11
    Join Date
    Aug 2006
    Posts
    559
    Quote Originally Posted by pkstormy
    Ouch...I looked at this code this last weekend and I didn't really like it because it does a lot of stuff (including opening hidden forms) while the recordset is open (i.e. rst and rst1). Give me a bit.

    Yeah, I didn't do it! Trust me! You can tell just by what I know I didn't do it!

    I found the securitydb demo on the net when doing a search cause I didn't want to use the ULS that embedded into Access!

    Thanks for takin' a gander at it though.

  12. #12
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Ok...I did this fairly quickly but here's what I added (*** Added PK). Copy the Function SetReminderNo to one of the modules (i.e. Check For Admin Security and NewUser) or any other module. Here's the code but I did this quickly and didn't have a lot of time to check it. On a side note, you NEED to debug as you have other places in code on some of the other forms which have errors.

    Private Sub cmdOk_Click()
    '*** Added PK
    Dim RemindMeDate As Date
    Dim lngCount As Long

    If isPasswordOK(Me!txtPassword) = True Then
    DoCmd.Close acForm, "frmUserLogon"
    DoCmd.OpenForm "frmMainMenu"

    '*** Added PK
    RemindMeDate = Nz(DLookup("[RemindDate]", "[tblUsers]", "[User_Name] = '" & fOSUserName() & "'"), 0)
    If RemindMeDate < Date Then

    lngCount = Nz(DCount("DaysSinceOriginated", "qryReminder"), 0)

    If lngCount > 0 Then

    Select Case MsgBox("There are " & lngCount & " overdue tasks. Would you Would you like to view the overdue tasks?", vbYesNo + vbExclamation)

    Case vbYes

    DoCmd.Close acForm, "frmMainMenu" 'closes frmMainMenu form if the user selects "Yes" to view the reminders
    DoCmd.OpenForm "frmReminders"

    Case vbNo
    Call SetReminderNo
    DoCmd.OpenForm "frmMainMenu"

    End Select

    End If
    End If
    '*** End Add

    Else

    ' MsgBox "Password incorrect....try again."
    ' Modify this with your code below
    'End If
    'Exit Sub

    On Error GoTo Err_cmdOk_Click
    '-----------------------------------------------------------------------------------------------------------------------------
    ' This code is used to validate users found in the tblSecurity table. If the wrong user name or password is
    ' provided access is denied.
    ' Created by: Richard Rensel
    ' Date Created: 18 Feb 2002
    ' Modified by Nick Phillips
    ' MODIFICATIONS: If Wrong Name/password is entered, then the NT login name is grabbed and updated to tblFailedAttempts
    ' Also if the wrong password is entered three times the Login is disabled until it is unlocked by an Admin
    ' This will now check to see if the person is denied access, and if they are the DB is closed, and also if their
    ' password has been reset they are forced to change their password once they enter in the random reset password
    ' Date Modified: 19 feb 2002
    '-----------------------------------------------------------------------------------------------------------------------------
    Dim db As DAO.Database
    Dim rst As DAO.Recordset
    Dim rst1 As DAO.Recordset
    Dim rstV As Recordset
    Dim stDocName As String
    Dim stLinkCriteria As String

    Set db = CurrentDb()
    Set rst = db.OpenRecordset("tblSecurity", dbOpenDynaset)

    If Not IsNull(Me.txtUser) And Not IsNull(Me.txtPassword) Then
    rst.FindFirst "Password = '" & Me.txtPassword & "'" & " And UserID = '" & Me.txtUser & "'"

    '----------------------------------------
    'If their is a problem logging in the NT username is grabbed and appended to tblFailedAttempts. The reason
    'I chose the NT login in name vs. the UserID, is because many times people will browse a network and find
    'A database and start trying to break-in. This way you can get them the first time they enter a wrong name/PW
    'This WILL NOT let you know if a valid user is attempting to log-in while signed onto a computer under another
    'NT log-in name

    If rst.NoMatch Then
    Set rst1 = db.OpenRecordset("tblFailedAttempts", dbOpenDynaset)
    With rst1
    .AddNew
    ![computer_login] = Me.txtUser_hidden
    .Update
    '*** Added PK
    rst.Close 'MAKE SURE TO DO THIS
    Set rst = Nothing 'MAKE SURE TO DO THIS
    '*** End Add
    End With
    MsgBox "You entered the wrong User Name or Password." & Chr(13) & _
    "Please enter the correct User Name and Password or " & Chr(13) & _
    "contact the Database Adminstrator for assistance.", vbOKOnly + vbCritical, "Logon Denied"
    'This counts how many times a user has typed in the wrong UserID/Password combo. After three attempts the user is
    'suspended from the DB, and cannot get access until their account is reset by the Admin

    cnt = cnt + 1 'increment counter if wrong password entered
    If cnt = 3 Then 'Set up number of tries
    'Display Message Box
    MsgBox "Access Violation Program Will Now Close", , "Violation Detected"
    DoCmd.OpenForm "frmPWChangeCheck", , , , , acHidden
    [Forms]![frmPWChangeCheck]![Active] = False
    DoCmd.Quit 'quit application and close Access
    End If

    ElseIf Me.txtPassword = "password" Then
    JumpIn:


    MsgBox "This is the first time using the database or your password has been reset." & Chr(13) & _
    "You must change your password before you can enter the database.", _
    vbOKOnly + vbExclamation, "Change Password"

    JumpIn1:
    stDocName = "frmUserLogonNew"
    stLinkCriteria = "[UserID]=" & "'" & Me![txtUser] & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Else
    'This opens another hidden form, that has two values on it... PWChange, and Active. If the active check box
    'is blank, then the user is denied access to the database. This value gets set to "NEW" When a users password
    'is reset from the Admin Users form. This next if/then statement checks to see if the word "NEW" is there
    'and if it is, then it forces the user to change it by going back above with the JumpIn: statement!!

    DoCmd.OpenForm "frmPWChangeCheck", , , , , acHidden

    If [Forms]![frmPWChangeCheck]![Active] = False Then
    MsgBox "Your Database privileges have been revoked" & Chr(13) & _
    "Please contact the Database Administrator for assistance", vbOKOnly + vbCritical, "Logon Denied"
    DoCmd.Quit
    Else
    If [Forms]![frmPWChangeCheck]![PWChange] = "New" Then
    GoTo JumpIn:
    Else



    '############This is the password DATE validation code #############

    DoCmd.OpenForm "frmPasswordHistory", , , , , acHidden

    Select Case Forms!frmPasswordHistory.DaysOld

    '**** NOTE: I couldn't copy the Case statements because it was too lengthy for the post. LEAVE the Case statements in your code...

    '############# END PASSWORD DATE VALIDATION CODE##################

    DoCmd.Close acForm, "frmUserLogon", acSaveNo 'close the frmUserLogon screen
    stDocName = "frmMainMenu" 'open frmMainMenu upon correct login being entered
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    '*** Added PK
    RemindMeDate = Nz(DLookup("[RemindDate]", "[tblUsers]", "[User_Name] = '" & fOSUserName() & "'"), 0)
    If RemindMeDate < Date Then

    lngCount = Nz(DCount("DaysSinceOriginated", "qryReminder"), 0)

    If lngCount > 0 Then

    Select Case MsgBox("There are " & lngCount & " overdue tasks. Would you Would you like to view the overdue tasks?", vbYesNo + vbExclamation)

    Case vbYes

    DoCmd.Close acForm, "frmMainMenu" 'closes frmMainMenu form if the user selects "Yes" to view the reminders
    DoCmd.OpenForm "frmReminders"

    Case vbNo
    Call SetReminderNo
    DoCmd.OpenForm "frmMainMenu"

    End Select

    End If
    End If
    '*** End Add


    End If
    End If
    End If
    Else
    MsgBox "You left the User Name and/or Password blank." & Chr(13) & _
    "Please enter the correct User Name and Password or " & Chr(13) & _
    "contact the Database Adminstrator for assistance.", vbOKOnly + vbCritical, "Logon Denied"
    End If

    With User
    .AccessID = rst.Fields("AccessID")
    .ViewID = rst.Fields("ViewID")
    .Active = rst.Fields("Active")
    .Password = rst.Fields("Password")
    .SecurityID = rst.Fields("SecurityID")
    .UserID = rst.Fields("UserID")
    End With

    rst.Close

    '*** Added PK
    Set rst = Nothing '**** Added - Make sure to do this!

    Exit_cmdOk_Click:
    Exit Sub


    Err_cmdOk_Click:
    MsgBox Err.Description
    Resume Exit_cmdOk_Click
    End If 'I added

    End Sub
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  13. #13
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    You'll notice in the post above that there are 2 places I added the check for Reminders. It's not ideal but what I could do quickly.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  14. #14
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I also see now that you may be able to remove the

    docmd.openform "frmMainMenu" after the line Call SetReminderNo...

    try it though.

    Case vbNo
    Call SetReminderNo
    DoCmd.OpenForm "frmMainMenu"
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  15. #15
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    AND MAKE SURE TO CLOSE and CLEAR YOUR RECORDSETS (i.e. rst and rst1 as noted above) when your done with them or you'll have problems!

    (see ***Added PK).
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •