Results 1 to 4 of 4
  1. #1
    mr_right is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2013
    Posts
    11

    Change Photo Depends on combo box value

    Hello!


    Good day!
    I have a log in form and combo box.
    Just want to ask if possible to change photo depends on combo box value?
    Hope someone will help me on this.
    Thanks in advance.
    Here is the link of my database.
    https://www.box.com/s/lodnawlcbuh9rjio3dzt

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    What you need to do is either filter the form to record with the photo or go to the record (unfiltered form).

    Include the EmpID field in the form's RecordSource. Will have to fix the image control ControlSource.

    Filter code:

    Private Sub Users_AfterUpdate()
    Me.Filter = "[EmpID]=" & Me.Users
    Me.FilterOn = True
    End Sub

    Don't understand purpose of AfterUpdate event code for image control. Can't edit value of image control.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    mr_right is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2013
    Posts
    11
    Thanks for your prompt response.
    I already did what you've said but i got an error
    "Run-time error '3709':
    The key was not found in any record when im trying to select on combo box
    here is my whole code on login form.
    Option Compare DatabasePrivate intLogonAttempts As Integer






    Private Sub cmdExit_Click()
    DoCmd.Quit acQuitSaveAll
    End Sub




    Private Sub cmdLogin_Click()


    'Check to see if data is entered into the UserName combo box


    If IsNull(Me.Users) Or Me.Users = "" Then
    MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
    Me.Users.SetFocus
    Exit Sub
    End If


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


    If IsNull(Me.Passtxt) Or Me.Passtxt = "" Then
    MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
    Me.Passtxt.SetFocus
    Exit Sub
    End If


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


    If Me.Passtxt.Value = DLookup("EmpPassword", "Usernames", "[EmpID]=" & Me.Users.Value) Then


    MyEmpID = Me.Users.Value


    'Enable ribbon and menu when log as Admin Account




    'Close logon form and open splash screen

    DoCmd.Close acForm, "LoginPOPUP", acSaveNo
    DoCmd.OpenForm "MainFrm"


    Else
    MsgBox "Password Invalid. Please Try Again", vbCritical + vbOKOnly, "Invalid Entry!"
    Me.Passtxt.SetFocus
    End If

    'If User Enters incorrect password 3 times database will shutdown

    intLogonAttempts = intLogonAttempts + 1
    If intLogonAttempts > 3 Then
    MsgBox "You do not have access to this database. Please contact your system administrator.", vbCritical, "Restricted Access!"
    Application.Quit
    End If

    End Sub


    Private Sub Users_AfterUpdate()
    Me.Filter = "[EmpID]=" & Me.Users
    Me.FilterOn = True
    End Sub


  4. #4
    mr_right is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2013
    Posts
    11
    I already got it.
    i forgot to incldue emp id on forms record source.
    Thanks..
    Problem solved.

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

Similar Threads

  1. Replies: 3
    Last Post: 12-11-2012, 09:12 AM
  2. Replies: 4
    Last Post: 08-29-2011, 12:36 PM
  3. How to set an image for a photo directory
    By eninen7 in forum Access
    Replies: 3
    Last Post: 01-11-2011, 12:24 PM
  4. One combo depends on another doesent work
    By scifo_dk in forum Forms
    Replies: 2
    Last Post: 11-26-2010, 04:25 AM
  5. Replies: 1
    Last Post: 10-22-2009, 03:32 AM

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