Results 1 to 6 of 6
  1. #1
    manic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    63

    Filtering Records Question

    Hello all.



    I have a form that is used to grade employees, it has three phases, 45,90 and 120 days review, I have it set up that after the 45 days scores are entered the user can go back and click a check mar that shows them the previous scores when they are going to enter the 90 days scores.

    the problem I have is the following:
    I found this code to filter the records based on a name selection:
    Code:
    Sub SetFilter()
    Dim LSQL As String
    'On Error Goto Err_LogErrors
    LSQL = "Select * from Tbl_Temp_Employee_Reviews_45_Days"
    LSQL = LSQL & " Where Employee_Name_45_Days ='" & CboSelected & "'"
    
    
    Form_SubForm_Temporary_Employee_Evaluation.RecordSource = LSQL
    'Exit_SetFilter:
    Exit Sub
    'Err_LogErrors:
    'Call LogErrors(Err.Number,Err.Description,"LSQL Failed Contact Administrator")
    'Resume Exit_SetFilet
    
    
    End Sub
    
    Private Sub Form_Open(Cancel As Integer)
        
        'Call subroutine to set filter based on selected Employee Name
        SetFilter
        
    End Sub
    
    Private Sub CboEmployee_Name_AfterUpdate()
        
        'Call subroutine to set filter based on selected Employee Name
        SetFilter
        
    End Sub
    when I select a name from the CboEmploye_Name which is an Unboundbox, the records don't show up however after i select a name from the box and the go to design view and then back, there it is the records are showing, what is causing this?
    why are the records only showing after i go to design view and back?
    I am attaching a rough sample, thanks in advance for all the help.SampleFile01.zip

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    There is no code for the AfterUpdate event of the combobox cboSelected. There is an AfterUpdate procedure for cboEmployee_Name but can't find a combobox with that name. Need to change name of one of these so they agree.
    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
    manic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    63
    Thank you much, I need to stop doing work when Im tired, LOL thanks again June7.

  4. #4
    manic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    63
    Quote Originally Posted by June7 View Post
    There is no code for the AfterUpdate event of the combobox cboSelected. There is an AfterUpdate procedure for cboEmployee_Name but can't find a combobox with that name. Need to change name of one of these so they agree.
    June7 it seems that I spoke too soon. I changed the name on the Cbo and they agree now, but the issue that comes up now is that the only record that shows up is the very first one on this combo box. The combo box has employee 1 and 2 and employee 1 is on th top and when i select that one those records appear no problem but when i select employee two nothing happens the record clear up and goes blank like there is no record for thi employee but i know for a fact that the record exist otherwise his nme would not be on that Cbo. any clues??

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    The code is setting RecordSource of the subform but Master/Child links are conflicting with this. Set RecordSource of main form. Or better, don't need form/subform. Copy all the subform controls onto main form and delete the subform container. And instead of setting RecordSource, set Filter.

    Private Sub CboSelected_AfterUpdate()
    Me.FilterOn = False
    Me.Filter = "Employee_Name_45_Days='" & Me.CboSelected & "'"
    Me.FilterOn = True
    End Sub
    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.

  6. #6
    manic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    63
    Quote Originally Posted by June7 View Post
    The code is setting RecordSource of the subform but Master/Child links are conflicting with this. Set RecordSource of main form. Or better, don't need form/subform. Copy all the subform controls onto main form and delete the subform container. And instead of setting RecordSource, set Filter.

    Private Sub CboSelected_AfterUpdate()
    Me.FilterOn = False
    Me.Filter = "Employee_Name_45_Days='" & Me.CboSelected & "'"
    Me.FilterOn = True
    End Sub
    Outstanding, thanks.

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

Similar Threads

  1. Question on database structure - limiting linked records
    By andrewb in forum Database Design
    Replies: 2
    Last Post: 03-22-2012, 05:41 PM
  2. Filtering/Querying Records using Selection Screen
    By Jonny333 in forum Programming
    Replies: 1
    Last Post: 12-22-2011, 08:56 PM
  3. Filtering records with a combo box
    By joesmithjunior in forum Access
    Replies: 1
    Last Post: 12-18-2011, 03:17 PM
  4. Quick question about deleting records
    By pinecrest515 in forum Queries
    Replies: 3
    Last Post: 12-14-2010, 10:58 AM
  5. Question on filtering a form
    By jbarrum in forum Forms
    Replies: 12
    Last Post: 02-15-2010, 11:38 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