Another Login form question

bodylojohn

Registered User.
Local time
Today, 11:16
Joined
Dec 28, 2005
Messages
205
Hello,

I have a login form containing just a combobox (login name) and a textfield (password). Well...this works perfect using the following code:

Code:
Private Sub cmdLogin_Click()

If IsNull(Me.cboLoginNaam) Or Me.cboLoginNaam = "" Then
      MsgBox "Selecteer een gebruikersnaam!", vbOKOnly, "Gebruikersnaam vereist"
        Me.cboLoginNaam.SetFocus
        Exit Sub
    End If

    'Check to see if data is entered into the password box

If IsNull(Me.txtWachtwoord) Or Me.txtWachtwoord = "" Then
      MsgBox "U dient een wachtwoord in te voeren!.", vbOKOnly, "Voer wachtwoord in"
        Me.txtWachtwoord.SetFocus
        Exit Sub
    End If

    'Check value of password in tblEmployees to see if this
    'matches value chosen in combo box

    If Me.txtWachtwoord.Value = DLookup("Wachtwoord", "tblGEBRUIKER", _
            "[Gebruiker_ID]=" & Me.cboLoginNaam.Value) Then

        Gebruiker_ID = Me.cboLoginNaam.Value

        'Close logon form and open splash screen

        DoCmd.Close acForm, "frmLogin", acSaveNo
        DoCmd.OpenForm "frmRELATIE_ZOEKSCHERM"

    Else
      MsgBox "Wachtwoord is ongeldig. Probeer het nogmaals", vbOKOnly, _
            "Invalid Entry!"
        Me.txtWachtwoord.SetFocus
    End If
End Sub

BUT...

I want to replace the combobox with a textbox so the user has to type his username.
I tried some changing the code but without success. I could find a lot of info on the board but saddly they where all using combo boxes.

Thanks in advance guys.
 
Well, gebruiker_ID seems to be an Integer, so cboLoginNaam is sure to have something like "Select gebruiker_ID, Gebruiker_Naam From tblGebruiker" as Rowsource and it's column widths set to 0;3(for example), while it's boundolumn number = 1. This means that the value returned by the cbobox is the first column (boundolumn number = 1), altough what u see in the combo is the 2nd column (GebruikerNaam). That's one of the powers of combos. Now if u want to select on the typed-in user name, u should change your lookup criteria from Gebruiker_ID to Gebruiker_Naam:

If Me.txtWachtwoord.Value = DLookup("Wachtwoord", "tblGEBRUIKER", _
"[Gebruiker_Naam]=" & "'" & Me.txtLoginNaam & "'") Then ...



HTH
Premy
 
Well, gebruiker_ID seems to be an Integer, so cboLoginNaam is sure to have something like "Select gebruiker_ID, Gebruiker_Naam From tblGebruiker" as Rowsource and it's column widths set to 0;3(for example), while it's boundolumn number = 1. This means that the value returned by the cbobox is the first column (boundolumn number = 1), altough what u see in the combo is the 2nd column (GebruikerNaam). That's one of the powers of combos. Now if u want to select on the typed-in user name, u should change your lookup criteria from Gebruiker_ID to Gebruiker_Naam:

If Me.txtWachtwoord.Value = DLookup("Wachtwoord", "tblGEBRUIKER", _
"[Gebruiker_Naam]=" & "'" & Me.txtLoginNaam & "'") Then ...



HTH
Premy


This works perfect.

THANK YOU very very much for all of your help.
 
You're welcome... don't forget to hit me scale ;-).

Regards,
Premy
 

Users who are viewing this thread

Back
Top Bottom