Results 1 to 9 of 9
  1. #1
    Hossein's Avatar
    Hossein is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Oct 2018
    Posts
    24

    Macro character limitation

    Hi dear friends

    I use below code in macro for filtering columns but macro has not accepted more than 255 character.


    How can do it ?

    Code:
    [CompanyLE] Like "*" & [Forms]![Search_PTP]![Search_Company] & "*" AND 
    [SBU] Like "*" & [Forms]![Search_PTP]![Search_SBU] & "*" AND 
    [Oerder_NO] Like "*" & [Forms]![Search_PTP]![Search_PO] & "*" AND 
    [Order_Date] Like "*" & [Forms]![Search_PTP]![OrderDate_Search] & "*" AND 
    [KhorshidiDate] Like "*" & [Forms]![Search_PTP]![GOD_Search] & "*" AND 
    [Note] Like "*" & [Forms]![Search_PTP]![Note_Serch] & "*" AND 
    [Currency] Like "*" & [Forms]![Search_PTP]![Currency_Search] & "*" AND 
    [Payment_Term] Like "*" & [Forms]![Search_PTP]![PaymentTerm_Search] & "*" AND 
    [IDH_Code] Like "*" & [Forms]![Search_PTP]![IDHCode_Search] & "*" AND 
    [Item Description] Like "*" & [Forms]![Search_PTP]![ItemDescription_search] & "*"
    Click image for larger version. 

Name:	255.jpg 
Views:	7 
Size:	75.5 KB 
ID:	35765

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    you can't - see this link https://www.databasezone.com/techdocs/acclimit.html

    255 is the max for any entry in a macro

    you will need to convert your macro to vba code

  3. #3
    Hossein's Avatar
    Hossein is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Oct 2018
    Posts
    24
    Quote Originally Posted by Ajax View Post
    you can't - see this link https://www.databasezone.com/techdocs/acclimit.html

    255 is the max for any entry in a macro

    you will need to convert your macro to vba code
    Thanks a lot.

  4. #4
    Hossein's Avatar
    Hossein is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Oct 2018
    Posts
    24
    Quote Originally Posted by Ajax View Post
    you can't - see this link https://www.databasezone.com/techdocs/acclimit.html

    255 is the max for any entry in a macro

    you will need to convert your macro to VBA code
    I am writing VBA code but i have same issue !!
    how can i move to next row ?

    Click image for larger version. 

Name:	89.jpg 
Views:	6 
Size:	101.2 KB 
ID:	35767

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    you need to assign the code to a string and build it

    Code:
    dim filterstr as string
    filterstr="[CompanyLE] Like '*" & [Forms]![Search_PTP]![Search_Company] & "*' AND.....
    note the use of single and double quotes to build the string

    to go to the next line use the underscore e.g.

    Code:
    filterstr="[CompanyLE] Like '*" & _
                        [Forms]![Search_PTP]![Search_Company] & "*' AND.....

    also, if this code is running in an event in your search_ptp form, you can replace [Forms]![Search_PTP]! with Me. e.g. me.search_company

  6. #6
    Hossein's Avatar
    Hossein is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Oct 2018
    Posts
    24
    Dear my friends
    I could found solution !
    For going to next line you can follow below example :

    Code:
    .Formula = Array("=IF(OR(ISNUMBER(SEARCH(""DC-9"",$E2)),ISNUMBER(SEARCH(""DC9"",$E2))),""DC-9"","""")", "=IF(OR(ISNUMBER(SEARCH(""DC-9-11"",$E2)),..... _
    ISNUMBER(SEARCH(""DC-9,-11"",$E2))),""DC-9"","""")")
    change to :

    Code:
        With rngTest
            .Formula = Array("=IF(OR(ISNUMBER(SEARCH(""DC-9"",$E2))," & _
            "ISNUMBER(SEARCH(""DC9"",$E2))),""DC-9"","""")", _
            "=IF(OR(ISNUMBER(SEARCH(""DC-9-11"",$E2))," & _
            "ISNUMBER(SEARCH(""DC-9,-11"",$E2))),""DC-9"","""")")
        End With

  7. #7
    Hossein's Avatar
    Hossein is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Oct 2018
    Posts
    24
    Many thanks

  8. #8
    Hossein's Avatar
    Hossein is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Oct 2018
    Posts
    24
    This is my final code
    Code:
    Private Sub Command1236_Click()
    
    DoCmd.ApplyFilter "Companyf", "[CompanyLE] Like ""*"" & [Forms]![Search_PTP]![Search_Company] & ""*"" and " & _
    "[SBU] Like ""*"" & [Forms]![Search_PTP]![Search_SBU] & ""*"" and " & _
    "[Oerder_NO] Like ""*"" & [Forms]![Search_PTP]![Search_PO] & ""*"" and " & _
    "[Order_Date] Like ""*"" & [Forms]![Search_PTP]![OrderDate_Search] & ""*"" and " & _
    "[KhorshidiDate] Like ""*"" & [Forms]![Search_PTP]![GOD_Search] & ""*"" and " & _
    "[Note] Like ""*"" & [Forms]![Search_PTP]![Note_Serch] & ""*"" and " & _
    "[Currency] Like ""*"" & [Forms]![Search_PTP]![Currency_Search] & ""*"" and " & _
    "[Payment_Term] Like ""*"" & [Forms]![Search_PTP]![PaymentTerm_Search] & ""*"" and " & _
    "[IDH_Code] Like ""*"" & [Forms]![Search_PTP]![IDHCode_Search] & ""*"" and " & _
    "[IDH_Name] Like ""*"" & [Forms]![Search_PTP]![ItemDescription_search] & ""*"" and " & _
    "[RMP] Like ""*"" & [Forms]![Search_PTP]![RMP_search] & ""*"" and " & _
    "[QTY] Like ""*"" & [Forms]![Search_PTP]![InvQuantity_search] & ""*"" and " & _
    "[Unit_Price] Like ""*"" & [Forms]![Search_PTP]![UnitPrice_search] & ""*""", ""
    
    
    End Sub

  9. #9
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    so VBA wasn't so bad!

    A couple of comments - name your controls with something meaningful - you will have forgotten what Command1236 is when you revisit your code some time in the future.

    you seem to be searching numeric values with Like - e.g. qty, price, which seems a bit odd to me - if you search for 12, you will also get 121, 1200, 1012, is that what you want?

    Also, Note and Currency are reserved words, using them as a field names is likely to cause strange error messages somewhere down the line - see this link for reserved words https://support.office.com/en-us/art...7-da237c63eabe

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

Similar Threads

  1. Replies: 18
    Last Post: 10-11-2017, 03:07 PM
  2. SubForm OrderDetails Limitation
    By francogaspari in forum Forms
    Replies: 7
    Last Post: 07-15-2014, 02:42 PM
  3. Crosstab Limitation
    By mf28446 in forum Queries
    Replies: 5
    Last Post: 06-18-2014, 10:12 AM
  4. Report generation with date limitation
    By MBA80 in forum Reports
    Replies: 5
    Last Post: 06-02-2012, 08:28 PM
  5. Exporting to Excel: Character Limitation?
    By Nosaj08 in forum Import/Export Data
    Replies: 1
    Last Post: 04-21-2010, 10:29 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