Results 1 to 10 of 10
  1. #1
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618

    Expression in a query

    TblUni020 = Dlookup(" TbluniID199 ","xAllTablesunion","FieldName199=’" & TradingName020 *& "’



    Both the fields FieldName199 and TradingName202 are strings, or words. What is wrong here?

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,842
    1 you have spaces either end of the field name you are looking up
    2 the single quotes look the wrong type of quote (but that might be the font)
    3 you have a surplus *
    4 you are missing a ") at the end
    5 you say you are using TradingName202 but are actually using TradingName020

  3. #3
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Thank you. Are you working night shift? I am a bit bit brain dead, but want to fix at least this one now. I tried TblUni020: DLookUp("TbluniID199","xAllTablesunion","FieldName 199='" & [TradingName020] &'")
    Click image for larger version. 

Name:	String01.png 
Views:	9 
Size:	19.5 KB 
ID:	41619

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,842
    you have now dropped the " before the last '

    No, not on nightshift - I'm in the UK so about the same time as you

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,842
    why not just bring the xAllTablesunion into your query and join on FieldName199 and TradingName020

  6. #6
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    My query "q01BusinessInfo" becomes not write able, linking those two fields. In the table xAllTablesunion it would have worked if I made Fieldname199 the primary key, but sometimes I need the same name to appear in that field, so it can not be the primary key. I set up a query of xAllTablesunion and filter that only records normally in q01BusinessInfo will be listed, by this time I believe I need the expression. So the latest, I added what you say but. TblUni020: DLookUp("TbluniID199","xAllTablesunion","FieldName 199='" & [TradingName020] &"'")
    Click image for larger version. 

Name:	String02.png 
Views:	8 
Size:	27.2 KB 
ID:	41620Click image for larger version. 

Name:	String03.png 
Views:	8 
Size:	15.1 KB 
ID:	41621

  7. #7
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,842
    you now have a space in FieldName199

    if there is supposed to be a space, you also need to use square brackets - [
    FieldName 199]

  8. #8
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    I have to do this link in about 150 of our 800 queries. q01BusinessInfo holds one record for it is the business for whom the books is held, but all other queries may have many records, and it is a bit of a long story for what I need it, I will spare you that. I learnt programming since 5 years ago, and have a list of many kinds of expressions, and more than 500 clips of downloads, but I still fall short knowing how to compare two words in the criteria part.

  9. #9
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Last week there was another thread that this happened to. Even when I clicked on "Edit" here on the forum the space disappeared. When I copied it here there was no space? But it works now, thank you.

  10. #10
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,842
    to preserve text formatting of code (SQL or VBA) you need to use the code tags.

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

Similar Threads

  1. Replies: 8
    Last Post: 01-11-2020, 04:31 AM
  2. Replies: 2
    Last Post: 11-16-2017, 03:33 AM
  3. Replies: 4
    Last Post: 05-03-2016, 01:51 PM
  4. Replies: 2
    Last Post: 11-20-2012, 03:21 AM
  5. Replies: 4
    Last Post: 10-26-2012, 12:49 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