Results 1 to 7 of 7
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839

    Lookup and Like

    I have a query where I want lookup a field in a reference table.

    tbleRef
    Wave
    Type
    Out

    TblA
    Nets
    Waves
    Sub

    I am trying to do something like this:
    Code:
    SELECT tblA.Waves, IIf([Nets] Like "*" & [Type] & "*",[Out],"") AS [Output]
    FROM tblref LEFT JOIN tblA ON tblref.Type = tblA.Waves
    WHERE (((tbla.WaveForms)="VHF"));
    TblRef.out
    CMD
    FS
    Fires
    F1..........................

    I have tried right/left/inner join but get multiple outs for the same row

    What I am attempting is to look at a part of tbla.Nets field where it is like one of the rows in tblref.type and display tblref.out

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I think there would be no join - you want every record in tblref to be compared to every record in tbla. Depending on the number of records, this could take a while. Do a prior query which filters the records, that will have less records to deal with.

  3. #3
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Maybe you should post some sample data and indicate the desired output. You're joining Type from one table to Waves in another, which might be perfectly OK, but the difference in field names makes one wonder. I find that copying/pasting in a post from Excel usually results in a nice quick table. Seems to work best if the source data is centered first.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    I've simplified it without a join and added an ID number to tblA

    Code:
    SELECT TblA.UID, IIf([Nets] Like "*" & [Type] & "*",[Out],"") AS test
    FROM TblA, TblRef
    WHERE (((IIf([Nets] Like "*" & [Type] & "*",[Out],""))<>"") AND ((TblA.Waves)="VHF"));
    Thanks

    Micron
    Database1.zip

  5. #5
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    What I am attempting is to look at a part of tbla.Nets field where it is like one of the rows in tblref.type and display tblref.out
    try
    Code:
    SELECT TblRef.Out
    FROM TblRef
    WHERE (((Exists (select * from tblA where TblA.Nets like "*" & tblRef.[Type] & "*"))<>False));
    If that's not right, I have no other clue because the data is very odd. If it is right, it is a miracle, because me and subqueries don't usually get along.
    BTW, "Type" is a poor name for any Access object since it's a reserved word.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Thanks Micron,
    Your codes gives 1 instance of what was output in the query.

  7. #7
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I take it that the subquery approach worked. In that case, glad to have helped.

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

Similar Threads

  1. Replies: 4
    Last Post: 03-17-2016, 07:16 AM
  2. Lookup values not appearing in Lookup field?
    By dominover in forum Access
    Replies: 4
    Last Post: 03-05-2016, 05:01 PM
  3. Replies: 4
    Last Post: 07-28-2015, 10:14 AM
  4. Replies: 3
    Last Post: 05-08-2015, 11:08 AM
  5. Replies: 5
    Last Post: 11-24-2014, 02:19 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