Results 1 to 7 of 7
  1. #1
    margzj is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Location
    Dubai
    Posts
    41

    Textbox Filter Contain in Datasheet

    Hi, I want to filter my Company Name with contain but my company name value is integer.



    I have this code for my other filter, this one is working. I am having trouble with my Company Name.

    Code:
    If Not IsNull(Me.ContactPerson) Then
        Forms("frmMain").Filter = "[ContactPerson] Like " & Chr(34) & "*" & Me.ContactPerson & "*" & Chr(34)
        Forms("frmMain").FilterOn = True
    End If
    Click image for larger version. 

Name:	table.jpg 
Views:	9 
Size:	67.5 KB 
ID:	29779

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    why would your 'name' be a number? why isnt it company#?
    but for numerics, dont use quotes:

    Code:
    If Not IsNull(Me.ContactPerson) Then
        me.Filter = "[CoNameID]=" &   Me.ID
        me.FilterOn = True
    End If

  3. #3
    margzj is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Location
    Dubai
    Posts
    41
    Quote Originally Posted by ranman256 View Post
    why would your 'name' be a number? why isnt it company#?
    but for numerics, dont use quotes:

    Code:
    If Not IsNull(Me.ContactPerson) Then
        me.Filter = "[CoNameID]=" &   Me.ID
        me.FilterOn = True
    End If
    If I search with this code, It will search exactly equal​ not contain.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Show us the code that is not working.

    Do you mean the CompanyInfo_ID field is integer and of course using a LIKE operator and wildcard in filter criteria on this field will not work.

    If you are filtering a form and want to use the CompanyName as criteria, then you need to include the CompanyInfo table in the form RecordSource.
    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.

  5. #5
    margzj is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Location
    Dubai
    Posts
    41
    Quote Originally Posted by June7 View Post
    Show us the code that is not working.

    Do you mean the CompanyInfo_ID field is integer and of course using a LIKE operator and wildcard in filter criteria on this field will not work.

    If you are filtering a form and want to use the CompanyName as criteria, then you need to include the CompanyInfo table in the form RecordSource.
    Yup that is my problem

  6. #6
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    you dont contain ID. they are exact.

  7. #7
    margzj is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Location
    Dubai
    Posts
    41
    Quote Originally Posted by June7 View Post
    Show us the code that is not working.

    Do you mean the CompanyInfo_ID field is integer and of course using a LIKE operator and wildcard in filter criteria on this field will not work.

    If you are filtering a form and want to use the CompanyName as criteria, then you need to include the CompanyInfo table in the form RecordSource.
    Hi thank you for the idea, I already solved the problem. I include the company name in the datasheet and hide it.

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

Similar Threads

  1. Replies: 8
    Last Post: 08-18-2016, 05:30 PM
  2. Replies: 3
    Last Post: 08-08-2016, 07:28 AM
  3. Replies: 4
    Last Post: 10-06-2012, 04:45 AM
  4. Replies: 16
    Last Post: 01-16-2012, 09:43 AM
  5. Replies: 6
    Last Post: 09-02-2010, 02:18 AM

Tags for this Thread

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