Results 1 to 10 of 10
  1. #1
    Vanita is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Feb 2019
    Posts
    23

    Find Records by selecting 3 fields in combo box

    Hi,
    How to find records by selecting 3 fields in combo box, such that we can edit the data in table.
    We are attaching Form Design and Query Picture .Please help me out.


    Click image for larger version. 

Name:	Capture.JPG 
Views:	32 
Size:	64.2 KB 
ID:	38879Click image for larger version. 

Name:	Capture1.JPG 
Views:	32 
Size:	61.4 KB 
ID:	38880

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,896
    I have never used ApplyFilter. I set form Filter and FilterOn properties. Review: http://allenbrowne.com/ser-62.html

    I don't think you have correct syntax for ApplyFilter. I cannot find an example using FilterName argument but I don't think it should be an SQL statement.
    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
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Replace the Docmd.ApplyFilter task line with Me.recordsource=task (and add Me.recordset-"Select * FROM Production_Monitoring_Table" in the first part of the if statement if the fields are empty).

    Cheers,
    Vlad

  4. #4
    Vanita is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Feb 2019
    Posts
    23
    Hi,
    Please check attachment and can u tell is this correct?

    Click image for larger version. 

Name:	Capture2.JPG 
Views:	19 
Size:	54.9 KB 
ID:	38941

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,896
    Should copy/paste code in post between CODE tags, not attach screenshot.

    Pick one control to SetFocus. As it is, cboShift will get focus.

    Remove the Me.Recordset line. As is, that should give you a debug error and certainly won't execute.
    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
    Vanita is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Feb 2019
    Posts
    23
    Hi,
    As you mentioned i should copy/paste code in post CODE.
    Code:

    Private Sub BtnSearch_Click()
    Call SearchBtn
    End Sub
    Sub SearchBtn()
    Dim strCriteria As String
    Dim task As String
    'Me.Refresh


    If IsNull(Me.cboOperatorName) Or IsNull(Me.cboProductionDate) Or IsNull(Me.cboShift) Then
    MsgBox "Please Enter the Required Details", vbInformation, "Date Required"
    Me.cboOperatorName.SetFocus
    'Me.cboProductionDate.SetFocus
    'Me.cboShift.SetFocus


    Else
    Me.Recordset - "Select * FROM Production_Monitoring_Table"
    strCriteria = "(([Operator_Name])='" & Me.cboOperatorName & "' And ([Production_Date])='" & Me.cboProductionDate & "' And ([Shift])='" & Me.cboShift & "')"
    task = "Select * from Production_Monitoring_Table where (" & strCriteria & ") OrderBy [Operator_Name]"
    'Me.RecordSource = task


    End If
    End Sub


    still its not working..


  7. #7
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    try this:
    Code:
    Private Sub BtnSearch_Click()
    Call SearchBtn
    End Sub
    Sub SearchBtn()
    Dim strCriteria As String
    Dim task As String
    'Me.Refresh
    
    
    If IsNull(Me.cboOperatorName) Or IsNull(Me.cboProductionDate) Or IsNull(Me.cboShift) Then
    MsgBox "Please Enter the Required Details", vbInformation, "Date Required"
    Me.cboOperatorName.SetFocus
    'Me.cboProductionDate.SetFocus
    'Me.cboShift.SetFocus
    
    
    Else
    
    strCriteria = "(([Operator_Name])='" & Me.cboOperatorName & "' And ([Production_Date])='" & Me.cboProductionDate & "' And ([Shift])='" & Me.cboShift & "')"
    task = "Select * from Production_Monitoring_Table where (" & strCriteria & ") OrderBy [Operator_Name]"
    'Me.RecordSource = task
    
    
    End If
    End Sub

  8. #8
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Try this:

    Code:
    Private Sub BtnSearch_Click()
    Call SearchBtn
    End Sub
    Sub SearchBtn()
    Dim strCriteria As String
    Dim task As String
    'Me.Refresh
    
    
    If IsNull(Me.cboOperatorName) Or IsNull(Me.cboProductionDate) Or IsNull(Me.cboShift) Then
          Me.Recordsource = "Select * FROM Production_Monitoring_Table OrderBy [Operator_Name];"
          MsgBox "Please Enter the Required Details", vbInformation, "Date Required"
          Me.cboOperatorName.SetFocus
         'Me.cboProductionDate.SetFocus
         'Me.cboShift.SetFocus
    Else
         strCriteria = "(([Operator_Name])='" & Me.cboOperatorName & "' And ([Production_Date])='" & Me.cboProductionDate & "' And ([Shift])='" & Me.cboShift & "')"
         task = "Select * from Production_Monitoring_Table where (" & strCriteria & ") OrderBy [Operator_Name]"
         Me.RecordSource = task
    
    End If
    End Sub
    Cheers,
    Vlad

  9. #9
    Vanita is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Feb 2019
    Posts
    23
    Error Message
    Click image for larger version. 

Name:	Capture.PNG 
Views:	10 
Size:	7.7 KB 
ID:	38949

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,896
    Text field parameters use apostrophe delimiter.
    Date/time field parameters use # delimiter.
    Number field parameters do not need delimiter.

    Names are poor unique identifiers. Really should use OperatorID for search/filter.
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 12-26-2013, 02:50 PM
  2. Find records using combo box and text box
    By ihaveaquestion in forum Forms
    Replies: 1
    Last Post: 10-02-2013, 02:53 PM
  3. Combo Box to find records from multiple tables
    By cbella625 in forum Access
    Replies: 3
    Last Post: 08-15-2013, 12:12 PM
  4. Selecting records based on 2 combo boxes
    By comteck in forum Database Design
    Replies: 1
    Last Post: 07-10-2012, 06:05 PM
  5. Can't find records in combo box
    By darklite in forum Forms
    Replies: 6
    Last Post: 07-07-2011, 02:33 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