Results 1 to 2 of 2

Thread: Null, not null SQL return

  1. #1
    Join Date
    May 2003
    Posts
    5

    Null, not null SQL return

    Hello all
    I am trying to run a sql statement, (without having to run stored procedures), that will lookup a value stored in a Record.field., otherwise ignore the value if it is blank. I have a field tied to a Microsoft Access form - ItemLocation. If the user selects a unique ItemLocation the report will attempt to locate all values within that ItemLocation. If the user decides to leave the field blank, I would like for it to return all values for every ItemLocation. If anyone can help, I would really appreciate it. I will attach code. My problem is the last line of this SQL statement. If F.ITemLocation is null, I get no data. I would like for it to return everything. Thank you.

    Code:
    SELECT DISTINCT
    B.BarCodeID,
    A.ItemDescription,
    A.ItemCategory,
    A.TypeOfItem,
    A.SerialNumber,
    B.ItemLocation,
    B.LocationID,
    B.LastUpdate,
    B.TrackItID,
    B.UserID
    FROM
    tblMISFixedAssetTable A,
    tblMISFixedAssetTable2 B
    WHERE A.BarCodeID = B.BarCodeID
    AND A.DisposalDate is null
    AND B.LastUpdate = (Select Max(C.LastUpdate)
    from tblMISFixedAssetTable2 C
    Where B.BarCodeID = C.BarCodeID)
    AND B.BarCodeID in (Select D.BarCodeID
    from tblMISFixedAssetTable3 D
    Where D.FiscalYear = (Select E.FiscalYear
    from tblReportFY E))
    AND B.ItemLocation = (Select F.ItemLocation
    from tblReportFY F)

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    I don't know much about access so don't blame me if this does not work


    SELECT DISTINCT
    B.BarCodeID,
    A.ItemDescription,
    A.ItemCategory,
    A.TypeOfItem,
    A.SerialNumber,
    B.ItemLocation,
    B.LocationID,
    B.LastUpdate,
    B.TrackItID,
    B.UserID
    FROM
    tblMISFixedAssetTable A,
    tblMISFixedAssetTable2 B
    WHERE A.BarCodeID = B.BarCodeID
    AND A.DisposalDate is null
    AND B.LastUpdate = (Select Max(C.LastUpdate)
    from tblMISFixedAssetTable2 C
    Where B.BarCodeID = C.BarCodeID)
    AND B.BarCodeID in (Select D.BarCodeID
    from tblMISFixedAssetTable3 D
    Where D.FiscalYear = (Select E.FiscalYear
    from tblReportFY E))
    AND IIF(B.ItemLocation is null,true, B.ItemLocation = (Select F.ItemLocation
    from tblReportFY F))

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •