Results 1 to 4 of 4
  1. #1
    siema24 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2017
    Posts
    22

    Limit ComboBox possible values to one value - username login

    Hi,
    I'm wondering how to limit combobox values, that can be chosen by database user, to one option - "username"
    So basicly, it should changes depending on who (which user) is working with my DB. I use standard login form, please check "Login" buton code I'm including below. The best way would be to remember username in some kind of a temp value and then pass it to combobox, am I correct?. Unfortunetly I'm not sure how to do it correctly, maybe you can help? Thanks in advance!


    Private Sub btnLogin_Click()


    Dim rs As Recordset
    Dim TempUserName As TempVars

    Set rs = CurrentDb.OpenRecordset("tbl1Employees", dbOpenSnapshot, dbReadOnly)

    rs.FindFirst "UserName='" & Me.txtUserName & "'"

    If rs.NoMatch = True Then
    Me.lblWrongUser.Visible = True
    Me.txtUserName.SetFocus
    Exit Sub
    End If
    Me.lblWrongUser.Visible = False

    If rs!Password <> Me.txtPassword Then
    Me.lblWrongPass.Visible = True
    Me.txtPassword.SetFocus
    Exit Sub
    End If
    Me.lblWrongPass.Visible = False


    If rs!EmployeeType_ID = 3 Then
    Dim prop As Property
    On Error GoTo SetProperty
    Set prop = CurrentDb.CreateProperty("AllowBypassKey", dbBoolean, False)

    CurrentDb.Properties.Append prop

    SetProperty:
    If MsgBox("Czy chcesz przywrócić funkcjonalność bypass key?", vbYesNo, "Allow Bypass") = vbYes Then
    CurrentDb.Properties("AllowBypassKey") = True
    Else
    CurrentDb.Properties("AllowBypassKey") = False
    End If

    End If

    DoCmd.OpenForm "FormularzNawigacji"
    DoCmd.Close acForm, Me.Name
    End Sub

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Assuming the combobox is on a different form, you could pass the username when you close the form similar to below

    Code:
    Sub GoToSecondPage()
        DoCmd.OpenForm "MySecondPage", acNormal, , , , , value to be passed
    End Sub
    
    ' Second form '
    Sub Form_Open(Cancel As Integer)
        If Not IsNull(Me.OpenArgs) Then
            lblShowEmployeeName.Value = Me.OpenArgs
        End If
    End Sub

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    If you only have one value, there's no need for a combo box.
    use a text box.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I agree with ranman --no need for combo.

    It would be helpful to readers if you described what you are trying to do in simple English - just as you would tell an 8 year old.
    Showing us code is telling us HOW you did something that is an issue. We need to know the something before offering focused responses/suggestions.

    free youtube video on Login Form by Steve Bishop

    Good luck.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 02-13-2017, 10:29 AM
  2. Replies: 11
    Last Post: 03-09-2015, 02:56 PM
  3. Username and passwod login using Form
    By Tom1 in forum Programming
    Replies: 4
    Last Post: 07-04-2012, 12:29 PM
  4. Replies: 3
    Last Post: 06-22-2012, 04:19 PM
  5. Recording UserName Login
    By Moonsitter53 in forum Access
    Replies: 1
    Last Post: 03-18-2011, 02:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums