Results 1 to 5 of 5
  1. #1
    NewProgramPerson is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2019
    Posts
    8

    Issue with AlphaNumberic Strings

    Hi:



    I use the following code to pass a string called Lens Type: from Start New Plate table to the current table

    =DLookUp("[Lens Type:]","[Start New Plate]","[Lens Type:]='" & [Lens Type:] & "'")

    It works well when the Lens Type: is all letters, but I have one string that contains both letters and numbers (string is MK5 Test). It won't pass this string. It will ignore it or pass a different string that is only letters. What am I doing wrong?

    Thanks

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,798
    I don't see how that works at all. You're saying Look up lens type in table Start New Plate where lens type = 'some value'
    If you know what 'lens type' is (because after all, you are passing a value as criteria) then there's nothing to look up.
    It shouldn't matter that the field contains letters and numbers as long as the field is text data type and the expression syntax is correct. What should matter is that the criteria and the value being looked up are not the same.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Also be aware that your field naming is very poor.

    Use only letters and numbers (exception is the underscore) for object names.
    Do not use spaces, punctuation or special characters in object names.
    Do not begin an object name with a number.
    Do not/should not use Look up FIELDS, multi-Value fields or Calculated fields in tables.


    Examples
    ----------
    Bad - Lens Type:
    Better - LensType or Lens_Type

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    you cannot use brackets as a param.
    if you are using a form, rename the textbox to txtType, then

    =DLookUp("[Lens Type:]","[Start New Plate]","[Lens Type:]='" & txtType & "'")

    (and yes, never use spaces nor colons in your field names.)

    if you are using a query, DONT use dlookup. Use a join to the lookup table.

  5. #5
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,471
    Maybe try 3 quotes on left and 4 on right "[Lens Type:]=""" & [Lens Type:] & """") or

    Maybe use string convert function
    "[Lens Type:]='" & CStr([Lens Type:]) & "'") Not sure if it will work in the line, might have to do like x = CStr([Lens Type:]), then in the line use "[Lens Type:]='" & x & "'")

    so
    Lens Type: is the name of your field in the table?

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

Similar Threads

  1. Comparing strings
    By GraeagleBill in forum Programming
    Replies: 4
    Last Post: 04-14-2018, 11:30 PM
  2. Query to add strings
    By cork in forum Queries
    Replies: 1
    Last Post: 05-06-2016, 03:34 PM
  3. strings coloured
    By snoopy in forum Programming
    Replies: 2
    Last Post: 10-17-2012, 01:46 AM
  4. Comparing Two strings issue
    By ganeshvenkatram in forum Access
    Replies: 2
    Last Post: 06-16-2011, 05:27 AM
  5. Grouping strings
    By Fre in forum Access
    Replies: 16
    Last Post: 04-24-2010, 03:46 PM

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