Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    vipa2000 is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2022
    Posts
    10

    Unhappy Trying to add Len criteria


    Please see attached image. I am using an unmatched query - displaying all those records in table IH06 where no record exists in IP18. In image 2 you can see the actual data. I need to limit records in IH06 where the characters <9 don't show. I have tried adding additional criteria columns with the Len command, but it keeps saying I have an extra ) or bounces it: The specified field functional loc# could refer to more than one table listed in the FROM clause of your SQL statement. I have specified the table! Not sure this is because i am specifying null across two same fields and trying to then apply a Len restriction? Thanks in advance.
    Attached Thumbnails Attached Thumbnails Screenshot 2022-09-13 153613.jpg   image2.jpg  

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,927
    This should be all you need to do?
    Attached Thumbnails Attached Thumbnails len.PNG  
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    vipa2000 is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2022
    Posts
    10
    Hi, I tried that. I have attached a further image. Am i trying to query the same data field twice?
    Click image for larger version. 

Name:	Screenshot 2022-09-13 184143.jpg 
Views:	14 
Size:	54.0 KB 
ID:	48709

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    vipa2000,

    Access does not work well with fields with names containing spaces and/or special characters eg #.
    May not be related to your current issue, but is known fact and best to avoid.

    Can you switch to SQL view in your query; then copy the SQL and post it in the forum.

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,927
    No need to do it twice anyway, use the original field.
    The display appears to have a ] at the end?

    The len() should emcompass the whole name of the field, especially if prefixed with table name.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Quote Originally Posted by Welshgasman View Post
    No need to do it twice anyway, use the original field.
    The display appears to have a ] at the end?

    The len() should emcompass the whole name of the field, especially if prefixed with table name.
    It has a leading [ as well, so not an issue?
    I agree, expression (Right, Left, Mid, whatever) does not know which table the field refers to. Another reason to not have the same field name in multiple tables. It should be FunctionalLocPK and FunctionalLocFK or some derivative of that - assuming it is a pk / fk relationship.
    Last edited by Micron; 09-13-2022 at 12:19 PM. Reason: added comment
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    vipa2000 is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2022
    Posts
    10
    Hi, I did wonder about this. This is a data extract from a system called SAP so I was trying to use data as is; SAP is also unique. I think I fell foul of this before. I'll re-tweak the tables.

  8. #8
    vipa2000 is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2022
    Posts
    10
    Hi Micron, the table is defined in the query table? The data tables are raw outputs from SAP so I am trying not to tweak columns if I can.

  9. #9
    vipa2000 is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2022
    Posts
    10
    I have just noticed the SAP raw data contains the period symbol at the end. Access has converted these to #. I have found this - Names of fields, controls, and objects in Microsoft Access desktop databases: Can be up to 64 characters long. Can include any combination of letters, numbers, spaces, and special characters except a period (.), an exclamation point (!), an accent grave (`), and brackets ([ ]). Can't begin with leading spaces.

  10. #10
    vipa2000 is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2022
    Posts
    10
    Right, I have removed the period (.) and I have also removed the column called Functional Loc from table IH06 and just left the Len in. Issue remains. Perhaps to clarify the requirements here. The query (without the Len field embedded) produces a table that shows me where I have Functional locations IH06 without SAP plans IP17 (in the original screen shot I include the field - far right: it's blank). The issue I have is, I know that certain functional locations of a known size (length - 8 characters) do not have SAP plans so all I am trying to do is exclude the locations <9. Hope this make sense

    Click image for larger version. 

Name:	Screenshot 2022-09-13 194459.jpg 
Views:	12 
Size:	66.3 KB 
ID:	48710

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,927
    The Len() should include the table name I would have thought? Len(IH06![Functional Loc#])
    The display shows IH06.[Len(.....
    I have no clue how Access would interpret that?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  12. #12
    vipa2000 is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2022
    Posts
    10
    Sorry missed table ref out - added in
    Click image for larger version. 

Name:	Screenshot 2022-09-13 203008.jpg 
Views:	10 
Size:	39.7 KB 
ID:	48711

  13. #13
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    IMO you're not getting it. Functional Loc is in both tables, so your expression/calculation does not know which table you're referring to. So
    Len(IHO6.[Functional Loc#]) not

    IH06.Len([Functional Loc]
    AFAIC, the # is not an issue, especially considering how you ended up with it. Access would require [Field Name] wherever field contains spaces, allowed special characters, or Heaven forbid, the field name starts with a number.

    EDIT - to clarify, not the issue, but not a good design choice either if the developer does it on purpose.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  14. #14
    vipa2000 is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2022
    Posts
    10
    Bingo Micron. Thank you. Totally get what you have specified but thought I was specifying the table in the grid: see elements in green below. Does this not work for user defined queries?
    Click image for larger version. 

Name:	Screenshot 2022-09-13 203008.jpg 
Views:	8 
Size:	40.2 KB 
ID:	48713

  15. #15
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,927
    You have been asked to show the SQL generated, not the design window?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 08-17-2020, 10:10 AM
  2. Replies: 1
    Last Post: 08-15-2016, 05:56 AM
  3. Replies: 2
    Last Post: 04-02-2015, 12:45 PM
  4. Replies: 4
    Last Post: 08-30-2014, 10:23 AM
  5. Replies: 5
    Last Post: 08-02-2012, 09:44 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