Results 1 to 12 of 12
  1. #1
    raychow22 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    145

    Filtering Search Form

    Hi Forum,



    Can anyone help me with my accdb. I basically used http://allenbrowne.com/ser-62.html sample db for creating "Search Form".

    the Table is called "tblInspectionReport"
    the Form I want to create the Form in is "frmSearchForm"

    I got as far as setting up my form; however, the I am having trouble coding it to filter my search. The search criteria is based on "Segment", "WorkArea", "InspectorName", & "Dates_of_Inspection"

    Thanks,searchForm8.16.17.zip

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    What is the 'trouble'? What conditions produce the issue? What happens - error message, wrong results, nothing?

    Work Area and Inspector comboboxes are providing text values. Text parameters need apostrophe or quote delimiters. Use one of Allen's examples for text data.

    Or fix the comboboxes to return numeric ID. Make them multi-column, example for WorkArea:

    RowSource: SELECT WAID, WorkAreaNumber FROM tblWAID;
    ColumnCount: 2
    ColumnWidths: 0";1"
    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
    raychow22 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    145
    Quote Originally Posted by June7 View Post
    What is the 'trouble'? What conditions produce the issue? What happens - error message, wrong results, nothing?

    Work Area and Inspector comboboxes are providing text values. Text parameters need apostrophe or quote delimiters. Use one of Allen's examples for text data.

    Or fix the comboboxes to return numeric ID. Make them multi-column, example for WorkArea:

    RowSource: SELECT WAID, WorkAreaNumber FROM tblWAID;
    ColumnCount: 2
    ColumnWidths: 0";1"
    June7,

    Am I supposed to use the combo box example code from Allen, that looks like this

    'Yes/No field and combo example. If combo is blank or contains "ALL", we do nothing.
    'If Me.cboFilterIsCorporate = -1 Then
    'strWhere = strWhere & "([IsCorporate] = True) AND "
    'ElseIf Me.cboFilterIsCorporate = 0 Then
    'strWhere = strWhere & "([IsCorporate] = False) AND "
    'End If

  4. #4
    raychow22 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    145
    Click image for larger version. 

Name:	2017-08-16 11_32_58-Access - searchForm8.16.17 _ Database- C__Users_QEI_Documents_Calmod_Access .png 
Views:	21 
Size:	14.3 KB 
ID:	29969

    The problem is doesn't display anything. I noticed something at the bottom of the picture.

  5. #5
    raychow22 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    145
    My code looks like the following:

    'Segment filter
    If Not IsNull(Me.cboFilterSegment) Then
    strWhere = strWhere & "([Segment] = ""*" & Me.cboFilterSegment & "*"") AND "
    End If

    'Work Area filter
    If Not IsNull(Me.cboFilterWorkArea) Then
    strWhere = strWhere & "([WorkArea] = ""*" & Me.cboFilterWorkArea & "*"") AND "
    End If

    'InspectorName filter
    If Not IsNull(Me.cboFilterInspectorName) Then
    strWhere = strWhere & "([InspectorName] = ""*" & Me.cboFilterInspectorName & "*"") AND "
    End If

    'Deficiencies filter
    If Not IsNull(Me.cboFilterDeficiencies) Then
    strWhere = strWhere & "([Deficiencies] = ""*" & Me.cboFilterDeficiencies & "*"") AND "
    End If

    'Date field example. Use the format string to add the # delimiters and get the right international format.
    If Not IsNull(Me.txtStartDate) Then
    strWhere = strWhere & "([Date_Of_Inspection] >= " & Format(Me.txtStartDate, conJetDate) & ") AND "
    End If

    'Another date field example. Use "less than the next day" since this field has times as well as dates.
    If Not IsNull(Me.txtEndDate) Then 'Less than the next day.
    strWhere = strWhere & "([Date_Of_Inspection] < " & Format(Me.txtEndDate + 1, conJetDate) & ") AND "
    End If

  6. #6
    raychow22 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    145
    Click image for larger version. 

Name:	unfiltered.png 
Views:	19 
Size:	22.8 KB 
ID:	29971Click image for larger version. 

Name:	filtered.png 
Views:	19 
Size:	17.6 KB 
ID:	29970

    Here's what happens when it's unfiltered and when I try to filter "Segment" combobox

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Yes, I expect the Yes/No code should work with Deficiencies value.

    Did you make adjustments as suggested for WorkArea and Inspector?
    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.

  8. #8
    raychow22 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    145
    Click image for larger version. 

Name:	good.png 
Views:	18 
Size:	13.7 KB 
ID:	29975

    Ok I furthered my progress. I removed the asterisk***** from the code and it worked. Only thing I need to fix is the Inspector Name.. it displays the initials which is the first column in the row source. Is there a way to make it bound to the second column (Written out Name).

    Thanks, Here's a picture.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Your code can reference combobox columns by index. Index begins with 0. Column 2 would be index 1.

    Me.cboFilterInspectorName.Column(1)

    Again, filtering on autonumber unique ID primary key would be better.

    tblLABnames is not normalized structure.

    Name parts should be in separate fields: LName, FName, MName
    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.

  10. #10
    raychow22 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    145
    Okay! Almost there...
    Click image for larger version. 

Name:	query.png 
Views:	18 
Size:	20.8 KB 
ID:	29977Click image for larger version. 

Name:	query2.png 
Views:	18 
Size:	21.2 KB 
ID:	29978

    I want my Report Name to be FileName: Format([DateofInspection],"yyyy-mm-dd") & "-" & [InspectorName]; however the "InspectorName" I only want it to be the initials for example "Raymond Chow" = "RC".

    I have a table with two fields for full name and initals. Where do I start?

  11. #11
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    I NEVER set lookups in table. http://access.mvps.org/Access/lookupfields.htm

    If the name parts were in separate fields, the initials could be calculated.

    To make both name and initials available for display, have to include tblQEInames in the form RecordSource.

    FileName: Format([Date of Inspection], "yyyy-mm-dd") & "-" & [QEIinitials]
    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: 12
    Last Post: 06-06-2017, 11:02 AM
  2. Replies: 3
    Last Post: 09-12-2016, 11:49 AM
  3. Replies: 10
    Last Post: 09-08-2016, 08:09 PM
  4. Replies: 1
    Last Post: 09-04-2013, 03:24 PM
  5. Replies: 1
    Last Post: 04-20-2012, 03:16 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