Drop-down (incomplete result) (1 Viewer)

Danny

Registered User.
Local time
Today, 05:54
Joined
Jul 31, 2002
Messages
140
Greetings,

We’re currently running access 2016 split database (with individual front-end and shared back-end)

Couple of questions:

1. We have a form with a drop-down whereby users select either P: Providers or C: Clients to populate the name of the provider or the client. However, the list that is populated is not complete (e.g. provider name that starts with the letter (P-Z) did not show in the list. I checked the tables to verify the provider names are up to date.

a. I checked properties > data tab > Record Source is blank
B. In design mode I also checked properties of the object’s name it shows cboType

2. Though we have a login form where users enter their credentials to log in, we noticed just clicking login will let users access to the application (without entering username & password)


TIA

Regards,
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:54
Joined
Feb 19, 2013
Messages
16,616
1. what is the sql used to populate your list?
2. what is the code you are using for login?
 

Danny

Registered User.
Local time
Today, 05:54
Joined
Jul 31, 2002
Messages
140
CJ_London,

Thank you for the reply post.

re: what is the sql used to populate your list?

a. The database was designed by someone else. Where do I look to get
this info?

b. When looking at the table, there are over 72000 records. Can this be a
limit issue that a combo box can display?

re: what is the code you are using for login?

Are you referring to on click event for the login button?
open logon form in design mode > Right click logon > Properties > on Click event

If so, it’s very long. Please let me know how to post this code.

TIA

Regards,
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:54
Joined
Sep 21, 2011
Messages
14,311
CJ_London,

Thank you for the reply post.

re: what is the sql used to populate your list?

a. The database was designed by someone else. Where do I look to get
this info?

b. When looking at the table, there are over 72000 records. Can this be a
limit issue that a combo box can display?

re: what is the code you are using for login?

Are you referring to on click event for the login button?
open logon form in design mode > Right click logon > Properties > on Click event

If so, it’s very long. Please let me know how to post this code.

TIA

Regards,

Danny,

I got caught out recently on the login scenario.
I was testing for the value equal the password, but if the value was null, it let you straight in?

I changed it to Nz(ControlName,"BadPassword" or something like that, so that i would never match a password in the system, unless that was BadPassword :D

HTH
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:54
Joined
Feb 19, 2013
Messages
16,616
the rowsource can be found by

open form in design mode > Right click combo > Properties > Data Tab > Rowsource.

It may be the name of your table, or a query or it might be sql. if it is the name of a query, open the query in design view, select the sql button (top left of the ribbon) and copy the sql from there. If it is a table, open the table in design view and do a screenshot of the field - need to be able to see the names of the fields and their datatypes. If you can't upload the screenshot (see advanced editor), you'll need to type the names and type e.g.

ID autonumber
customername text
etc

Also, provide the name of the combobox (in properties, other tab)

72000 is too many - the limit is 65000. You will need to filter the list in some way. Provide the information above I and I can suggest what you can do.

For login, to copy code, highlight and copy. Then in the advanced editor paste the code and use the code tags (the # button) to surround what you have pasted. This preserves indentation and makes the code easier to read.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:54
Joined
Feb 19, 2013
Messages
16,616
link is basically what I was going to suggest - but since it has been done.....
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:54
Joined
Feb 19, 2013
Messages
16,616
Allen Browns solution also has a side benefit - the form should load quicker because the rowsource does not need to be populated at load time, and when it is populated, it will be with a significantly smaller dataset.
 

Danny

Registered User.
Local time
Today, 05:54
Joined
Jul 31, 2002
Messages
140
Thanks CJ_London

Sorry I didn't reply to your previous questions as I was not at work.

1. re: open form in design mode > Right click combo > Properties > Data Tab > Rowsource

Control Source: blank
Row Source: P: Providers or C: Clients
Row Source Type: Value List


re: Also, provide the name of the combobox (in properties, other tab)
Name: cboCasType

2. For login, below is the code that is used on click event
(note, for some reasons it was commented….)
Code:
Option Compare Database
Public gblUserNm As String
Private Sub cmdClose_Click()
'Close The Login and Close Database Once Cancel It Clicked
On Error GoTo err_cmdClose_Click

DoCmd.Quit

Exit_cmdClose_Click:
    Exit Sub
    
err_cmdClose_Click:
    MsgBox Err.Description
    Resume Exit_cmdClose_Click
    
End Sub

Private Sub cmdLOGIN_Click()
'Enable certain options on the main menu screen depending on access level
    'If Me.txtPWD Like "SU*" Then
    '    Forms!frmMainMenu!optMaintenance.Enabled = False
    'Else
    '    If Me.txtPWD Like "US*" Then
    '        Forms!frmMainMenu!optReports.Enabled = False
    '        Forms!frmMainMenu!optSuspCase.Enabled = False
    '        Forms!frmMainMenu!optMaintenance.Enabled = False
    '    End If
    'End If
    DoCmd.OpenForm "frmMainMenu"
    Me.Visible = False
    
End Sub

Private Sub Form_Open(Cancel As Integer)
'Once Form Is Open Enable Everything and Set Focus To User Name Field
    Application.SetOption "Confirm Action Queries", False
    Me.txtAttempts = 0
    Me.txtUserNm.SetFocus
End Sub

Private Sub txtPWD_AfterUpdate()
'Password validation
Dim db As DAO.Database
Dim rstUser As DAO.Recordset
Dim strUserNm As String
Dim intNum As Integer

'Set db = CurrentDb     'set db to PICTS DB
Set db = OpenDatabase("S:\OIG PICTS DB\ADMIN\PICTS DB_be")
Set rstUser = db.OpenRecordset("tblLOGIN")
strUserNm = txtUserNm
rstUser.Index = "USERNM"
rstUser.Seek "=", strUserNm

If rstUser!EncryptPWD = Me.txtPWD Then
    'Enable certain options on the main menu screen depending on access levels
    If Me.txtPWD = "SU900Sus" Then
        DoCmd.OpenForm "frmMainMenu"
        Forms!frmMainMenu!optMaintenance.Enabled = False
        Forms!frmMainMenu!optMCO.Enabled = True
        'DoCmd.Close acForm, "frmLogin"
    Else
        If Me.txtPWD Like "su503Eri" Then
            DoCmd.OpenForm "frmMainMenu"
            Forms!frmMainMenu!optMCO.Enabled = False
            Forms!frmMainMenu!optComplaint.Enabled = True
            Forms!frmMainMenu!optSuspCase.Enabled = False
            Forms!frmMainMenu!optMaintenance.Enabled = False
        Else
            If Me.txtPWD Like "SU*" Then
                DoCmd.OpenForm "frmMainMenu"
                Forms!frmMainMenu!optReports.Enabled = True
                Forms!frmMainMenu!optMaintenance.Enabled = False
                Forms!frmMainMenu!optMCO.Enabled = False
                Forms!frmMainMenu!optComplaint.Enabled = False
            Else
                If Me.txtPWD Like "us502Mic" Then
                    DoCmd.OpenForm "frmMainMenu"
                    Forms!frmMainMenu!optReports.Enabled = False
                    Forms!frmMainMenu!optComplaint.Enabled = True
                    Forms!frmMainMenu!optSuspCase.Enabled = False
                    Forms!frmMainMenu!optMaintenance.Enabled = False
                    Forms!frmMainMenu!optMCO.Enabled = False
                Else
                    If Me.txtPWD Like "us501Tan" Then
                        DoCmd.OpenForm "frmMainMenu"
                        Forms!frmMainMenu!optReports.Enabled = False
                        Forms!frmMainMenu!optComplaint.Enabled = True
                        Forms!frmMainMenu!optSuspCase.Enabled = False
                        Forms!frmMainMenu!optMaintenance.Enabled = False
                        Forms!frmMainMenu!optMCO.Enabled = True
                     Else
                        If Me.txtPWD Like "us601Sur" Then
                            DoCmd.OpenForm "frmMainMenu"
                            Forms!frmMainMenu!optReports.Enabled = False
                            Forms!frmMainMenu!optComplaint.Enabled = True
                            Forms!frmMainMenu!optSuspCase.Enabled = False
                            Forms!frmMainMenu!optMaintenance.Enabled = False
                            Forms!frmMainMenu!optMCO.Enabled = False
                            'DoCmd.Close acForm, "frmLogin"
                        Else
                            If Me.txtPWD Like "US*" Then
                                DoCmd.OpenForm "frmMainMenu"
                                Forms!frmMainMenu!optReports.Enabled = False
                                Forms!frmMainMenu!optComplaint.Enabled = False
                                Forms!frmMainMenu!optMaintenance.Enabled = False
                                Forms!frmMainMenu!optMCO.Enabled = False
                            Else
                                If Me.txtPWD Like "AD*" Then
                                    DoCmd.OpenForm "frmMainMenu"
                                    'DoCmd.Close acForm, "frmLogin"
                                Else
                                    If Me.txtPWD = "oig901ml" Then
                                        DoCmd.OpenForm "frmMainMenu"
                                        Forms!frmMainMenu!optMaintenance.Enabled = False
                                    End If
                                End If
                            End If
                        End If
                    End If
                End If
            End If
        End If
    End If
Else
    MsgBox "Password Is Invalid - Try Again!", vbCritical + vbOKOnly, "INVALID PASSWORD"
    Me.txtInvalidPW = "Y"
    Me.txtAttempts = Me.txtAttempts + 1
    If Me.txtAttempts = 3 Then
        MsgBox "Check Password And Try Again" & vbCrLf & "       GOOD-BYE", vbCritical + vbOKOnly, "TRY AGAIN LATER"
        DoCmd.Quit
       
    Else
         Me.txtPWD.SetFocus
         Me.cmdLOGIN.Enabled = False
    End If
End If

End Sub
Private Sub txtUserNm_AfterUpdate()
'User validation
Dim db As DAO.Database
Dim rstUser As DAO.Recordset
Dim strUserNm As String

'Set db = CurrentDb     'set db to PICTS DB
Set db = OpenDatabase("S:\OIG PICTS DB\ADMIN\PICTS DB_be")
Set rstUser = db.OpenRecordset("tblLOGIN")
strUserNm = Me.txtUserNm
gblUserNm = Me.txtUserNm
rstUser.Index = "USERNM"
rstUser.Seek "=", strUserNm
If rstUser.NoMatch = False Then
    Me.txtPWD.Enabled = True
    Me.txtPWD.SetFocus
    Me.txtValidUser = "Y"
Else
    MsgBox "No Match For User Name " & strUserNm, vbInformation + vbOKOnly, "INVALID USER NAME"
    Me.txtAttempts = Me.txtAttempts + 1
    If Me.txtAttempts = 3 Then
        MsgBox "Check User Name And Try Again" & vbCrLf & "          GOOD-BYE", vbCritical + vbOKOnly, "TRY AGAIN LATER"
        DoCmd.Close
    Else
        Me.txtUserNm = Null
        Me.txtUserNm.SetFocus
    End If
End If

End Sub

Private Sub txtUserNm_BeforeUpdate(Cancel As Integer)
'Check To See If User Are Valid. Look Into The Table To Get User Status
Dim strUser As String
Dim strStatus As String
Dim strSQL As String
Dim db As DAO.Database
Dim rstStatus As DAO.Recordset

Set db = OpenDatabase("S:\OIG PICTS DB\ADMIN\PICTS DB_be")
Set rstStatus = db.OpenRecordset("tblLOGIN")
strUser = Me.txtUserNm
rstStatus.Index = "USERNM"
rstStatus.Seek "=", strUser

If rstStatus!STATUS = "A" Then
    strStatus = rstStatus!STATUS
    Me.txtStatus = strStatus
End If

    If Me.txtStatus = "A" Then
        Me.txtPWD.Enabled = True
'        Me.txtPWD.SetFocus
        Me.txtValidUser = "Y"
    Else
        MsgBox "Invalid User Name Try Again" & vbCrLf & "          GOOD-BYE", vbCritical + vbOKOnly, "TRY AGAIN LATER"
        Me.txtValidUser = "N"
        Me.txtPWD.Enabled = False
        Me.cmdLOGIN.Enabled = False
        DoCmd.Quit
    End If
End Sub

Private Sub txtUserNm_GotFocus()
'Check Users Information If Valid Then Set Focus To Password Otherwise Close
    If Me.txtValidUser = "Y" And Me.txtInvalidPW = "Y" Then
        Me.txtPWD.SetFocus
    End If
    
End Sub
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:54
Joined
Feb 19, 2013
Messages
16,616
the reason your users go straight to the form without a password is that the code has been commented out.


Code:
Private Sub cmdLOGIN_Click()
'Enable certain options on the main menu screen depending on access level
   [COLOR=red] 'If Me.txtPWD Like "SU*" Then
    '    Forms!frmMainMenu!optMaintenance.Enabled = False
    'Else
    '    If Me.txtPWD Like "US*" Then
    '        Forms!frmMainMenu!optReports.Enabled = False
    '        Forms!frmMainMenu!optSuspCase.Enabled = False
    '        Forms!frmMainMenu!optMaintenance.Enabled = False
    '    End If
    'End If
[/COLOR]    DoCmd.OpenForm "frmMainMenu"
    Me.Visible = False
    
End Sub
Possibly because if you uncommented it, the form is not open so you get an error. Move the code to below the openform line
 

Danny

Registered User.
Local time
Today, 05:54
Joined
Jul 31, 2002
Messages
140
Thank you for the reply post

re: Possibly because if you uncommented it, the form is not open so you get an error.
Does this mean even if I uncomment it’s going to throw an error?

re: Move the code to below the openform line
Below the last OpenForm in the code below? DoCmd.OpenForm "frmMainMenu"

Code:
Private Sub cmdLOGIN_Click()
'Enable certain options on the main menu screen depending on access level
    If Me.txtPWD Like "SU*" Then
       Forms!frmMainMenu!optMaintenance.Enabled = False
     Else
          If Me.txtPWD Like "US*" Then
             Forms!frmMainMenu!optReports.Enabled = False
              Forms!frmMainMenu!optSuspCase.Enabled = False
             Forms!frmMainMenu!optMaintenance.Enabled = False
         End If
      End If
    DoCmd.[B][COLOR="Red"]OpenForm[/COLOR][/B] "frmMainMenu"
    Me.Visible = False
    
End Sub


Also, I’m running into a snug when attempting to test the login form: I created a development folder locally (desktop) for testing purposes. I copied both the BE/FE from the shared folder to the newly created dev. folder, and I establish the re-link to the new location. I then made changes and open the FE and enter my credentials, clicked ok nothing happens. I even tried cancel, no error but nothing is happening. I[m not sure what I’m doing wrong.

TIA,
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:54
Joined
Feb 19, 2013
Messages
16,616
Does this mean even if I uncomment it’s going to throw an error?
yes, because you are trying to modify a form that is not open

Below the last OpenForm in the code below? DoCmd.OpenForm "frmMainMenu"
yes

I don't see any 'OK' or 'cancel' button. Ar you referring to the cmdLogin button?
 

Danny

Registered User.
Local time
Today, 05:54
Joined
Jul 31, 2002
Messages
140
Thanks, CJ_London,

I uncommented and moved the code below the OpenForm

Code:
DoCmd.OpenForm "frmMainMenu"
Private Sub cmdLOGIN_Click()
'Enable certain options on the main menu screen depending on access level
    If Me.txtPWD Like "SU*" Then
       Forms!frmMainMenu!optMaintenance.Enabled = False
     Else
          If Me.txtPWD Like "US*" Then
             Forms!frmMainMenu!optReports.Enabled = False
              Forms!frmMainMenu!optSuspCase.Enabled = False
             Forms!frmMainMenu!optMaintenance.Enabled = False
             
            Me.Visible = False
         End If
      End If
End Sub

Please let me know if this correct?


TIA,
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:54
Joined
Feb 19, 2013
Messages
16,616
no, not correct - the openform is now not in a sub. It should be

Code:
Private Sub cmdLOGIN_Click()
'Enable certain options on the main menu screen depending on access level
 [COLOR=red] DoCmd.OpenForm "frmMainMenu"
[/COLOR]  If Me.txtPWD Like "SU*" Then
        Forms!frmMainMenu!optMaintenance.Enabled = False
    Else
        If Me.txtPWD Like "US*" Then
            Forms!frmMainMenu!optReports.Enabled = False
            Forms!frmMainMenu!optSuspCase.Enabled = False
            Forms!frmMainMenu!optMaintenance.Enabled = False
        End If
    End If
    
    Me.Visible = False
    
End Sub
 
Last edited:

Danny

Registered User.
Local time
Today, 05:54
Joined
Jul 31, 2002
Messages
140
cJ_London,

Thank you. I made the changes and included in the complete code below:

Code:
Option Compare Database
Public gblUserNm As String
Private Sub cmdClose_Click()
'Close The Login and Close Database Once Cancel It Clicked
On Error GoTo err_cmdClose_Click

DoCmd.Quit

Exit_cmdClose_Click:
    Exit Sub
    
err_cmdClose_Click:
    MsgBox Err.Description
    Resume Exit_cmdClose_Click
    
End Sub

Private Sub cmdLOGIN_Click()
'Enable certain options on the main menu screen depending on access level
  DoCmd.OpenForm "frmMainMenu"
  If Me.txtPWD Like "SU*" Then
        Forms!frmMainMenu!optMaintenance.Enabled = False
    Else
        If Me.txtPWD Like "US*" Then
            Forms!frmMainMenu!optReports.Enabled = False
            Forms!frmMainMenu!optSuspCase.Enabled = False
            Forms!frmMainMenu!optMaintenance.Enabled = False
        End If
    End If
    
    Me.Visible = False
    
End Sub

Private Sub Form_Open(Cancel As Integer)
'Once Form Is Open Enable Everything and Set Focus To User Name Field
    Application.SetOption "Confirm Action Queries", False
    Me.txtAttempts = 0
    Me.txtUserNm.SetFocus
End Sub

Private Sub txtPWD_AfterUpdate()
'Password validation
Dim db As DAO.Database
Dim rstUser As DAO.Recordset
Dim strUserNm As String
Dim intNum As Integer

'Set db = CurrentDb     'set db to PICTS DB
Set db = OpenDatabase("S:\OIG PICTS DB\ADMIN\PICTS DB_be")
Set rstUser = db.OpenRecordset("tblLOGIN")
strUserNm = txtUserNm
rstUser.Index = "USERNM"
rstUser.Seek "=", strUserNm

If rstUser!EncryptPWD = Me.txtPWD Then
    'Enable certain options on the main menu screen depending on access levels
    If Me.txtPWD = "SU900Sus" Then
        DoCmd.OpenForm "frmMainMenu"
        Forms!frmMainMenu!optMaintenance.Enabled = False
        Forms!frmMainMenu!optMCO.Enabled = True
        'DoCmd.Close acForm, "frmLogin"
    Else
        If Me.txtPWD Like "su503Eri" Then
            DoCmd.OpenForm "frmMainMenu"
            Forms!frmMainMenu!optMCO.Enabled = False
            Forms!frmMainMenu!optComplaint.Enabled = True
            Forms!frmMainMenu!optSuspCase.Enabled = False
            Forms!frmMainMenu!optMaintenance.Enabled = False
        Else
            If Me.txtPWD Like "SU*" Then
                DoCmd.OpenForm "frmMainMenu"
                Forms!frmMainMenu!optReports.Enabled = True
                Forms!frmMainMenu!optMaintenance.Enabled = False
                Forms!frmMainMenu!optMCO.Enabled = False
                Forms!frmMainMenu!optComplaint.Enabled = False
            Else
                If Me.txtPWD Like "us502Mic" Then
                    DoCmd.OpenForm "frmMainMenu"
                    Forms!frmMainMenu!optReports.Enabled = False
                    Forms!frmMainMenu!optComplaint.Enabled = True
                    Forms!frmMainMenu!optSuspCase.Enabled = False
                    Forms!frmMainMenu!optMaintenance.Enabled = False
                    Forms!frmMainMenu!optMCO.Enabled = False
                Else
                    If Me.txtPWD Like "us501Tan" Then
                        DoCmd.OpenForm "frmMainMenu"
                        Forms!frmMainMenu!optReports.Enabled = False
                        Forms!frmMainMenu!optComplaint.Enabled = True
                        Forms!frmMainMenu!optSuspCase.Enabled = False
                        Forms!frmMainMenu!optMaintenance.Enabled = False
                        Forms!frmMainMenu!optMCO.Enabled = True
                     Else
                        If Me.txtPWD Like "us601Sur" Then
                            DoCmd.OpenForm "frmMainMenu"
                            Forms!frmMainMenu!optReports.Enabled = False
                            Forms!frmMainMenu!optComplaint.Enabled = True
                            Forms!frmMainMenu!optSuspCase.Enabled = False
                            Forms!frmMainMenu!optMaintenance.Enabled = False
                            Forms!frmMainMenu!optMCO.Enabled = False
                            'DoCmd.Close acForm, "frmLogin"
                        Else
                            If Me.txtPWD Like "US*" Then
                                DoCmd.OpenForm "frmMainMenu"
                                Forms!frmMainMenu!optReports.Enabled = False
                                Forms!frmMainMenu!optComplaint.Enabled = False
                                Forms!frmMainMenu!optMaintenance.Enabled = False
                                Forms!frmMainMenu!optMCO.Enabled = False
                            Else
                                If Me.txtPWD Like "AD*" Then
                                    DoCmd.OpenForm "frmMainMenu"
                                    'DoCmd.Close acForm, "frmLogin"
                                Else
                                    If Me.txtPWD = "oig901ml" Then
                                        DoCmd.OpenForm "frmMainMenu"
                                        Forms!frmMainMenu!optMaintenance.Enabled = False
                                    End If
                                End If
                            End If
                        End If
                    End If
                End If
            End If
        End If
    End If
Else
    MsgBox "Password Is Invalid - Try Again!", vbCritical + vbOKOnly, "INVALID PASSWORD"
    Me.txtInvalidPW = "Y"
    Me.txtAttempts = Me.txtAttempts + 1
    If Me.txtAttempts = 3 Then
        MsgBox "Check Password And Try Again" & vbCrLf & "       GOOD-BYE", vbCritical + vbOKOnly, "TRY AGAIN LATER"
        DoCmd.Quit
       
    Else
         Me.txtPWD.SetFocus
         Me.cmdLOGIN.Enabled = False
    End If
End If

End Sub
Private Sub txtUserNm_AfterUpdate()
'User validation
Dim db As DAO.Database
Dim rstUser As DAO.Recordset
Dim strUserNm As String

'Set db = CurrentDb     'set db to PICTS DB
Set db = OpenDatabase("S:\OIG PICTS DB\ADMIN\PICTS DB_be")
Set rstUser = db.OpenRecordset("tblLOGIN")
strUserNm = Me.txtUserNm
gblUserNm = Me.txtUserNm
rstUser.Index = "USERNM"
rstUser.Seek "=", strUserNm
If rstUser.NoMatch = False Then
    Me.txtPWD.Enabled = True
    Me.txtPWD.SetFocus
    Me.txtValidUser = "Y"
Else
    MsgBox "No Match For User Name " & strUserNm, vbInformation + vbOKOnly, "INVALID USER NAME"
    Me.txtAttempts = Me.txtAttempts + 1
    If Me.txtAttempts = 3 Then
        MsgBox "Check User Name And Try Again" & vbCrLf & "          GOOD-BYE", vbCritical + vbOKOnly, "TRY AGAIN LATER"
        DoCmd.Close
    Else
        Me.txtUserNm = Null
        Me.txtUserNm.SetFocus
    End If
End If

End Sub

Private Sub txtUserNm_BeforeUpdate(Cancel As Integer)
'Check To See If User Are Valid. Look Into The Table To Get User Status
Dim strUser As String
Dim strStatus As String
Dim strSQL As String
Dim db As DAO.Database
Dim rstStatus As DAO.Recordset

Set db = OpenDatabase("S:\OIG PICTS DB\ADMIN\PICTS DB_be")
Set rstStatus = db.OpenRecordset("tblLOGIN")
strUser = Me.txtUserNm
rstStatus.Index = "USERNM"
rstStatus.Seek "=", strUser

If rstStatus!STATUS = "A" Then
    strStatus = rstStatus!STATUS
    Me.txtStatus = strStatus
End If

    If Me.txtStatus = "A" Then
        Me.txtPWD.Enabled = True
'        Me.txtPWD.SetFocus
        Me.txtValidUser = "Y"
    Else
        MsgBox "Invalid User Name Try Again" & vbCrLf & "          GOOD-BYE", vbCritical + vbOKOnly, "TRY AGAIN LATER"
        Me.txtValidUser = "N"
        Me.txtPWD.Enabled = False
        Me.cmdLOGIN.Enabled = False
        DoCmd.Quit
    End If
End Sub

Private Sub txtUserNm_GotFocus()
'Check Users Information If Valid Then Set Focus To Password Otherwise Close
    If Me.txtValidUser = "Y" And Me.txtInvalidPW = "Y" Then
        Me.txtPWD.SetFocus
    End If
    
End Sub

I'll try this in my test environment that I created locally & post back if I've any questions.

Regards,
 

Danny

Registered User.
Local time
Today, 05:54
Joined
Jul 31, 2002
Messages
140
cJ_London,

I just tried the modified code in my test environment. When the login form appears, I clicked 'Logon' (without entering my credentials) and it lets me in to the main menu.

TIA,
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:54
Joined
Feb 19, 2013
Messages
16,616
it will do because you don't have any code to check whether a password has been entered. The button should be disabled until something has been entered and verified.

You probably need this

Me.cmdLOGIN.Enabled = False

in your form open event

then some more code to enable it once validation is complete.
 

Users who are viewing this thread

Top Bottom