Results 1 to 5 of 5
  1. #1
    54.69.6d.20 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2012
    Posts
    21

    if statement in sql statement, query builder

    Need some help. This is a sub report that works in the report.



    SELECT mt_Inventory.I4206 AS SerialNumber, mt_Inventory.I4201 AS CustomerID, mt_Inventory.I4202 AS Manufacturer, mt_Inventory.I4203 AS [Model Number], mt_Inventory.I4204 AS Description, mt_Inventory.Room, mt_Inventory.Location, mt_Inventory.I4218 AS Dept
    FROM mt_Inventory
    WITH OWNERACCESS OPTION;

    But when I replace mt_Inventory.I4201, with mt_Inventory.IDOverride. It doesn't show on the report. IDOverride is part of the table, HOWEVER, I'm thinking

    SELECT mt_Inventory.I4206 AS SerialNumber, mt_Inventory.IDOverride AS CustomerID, mt_Inventory.I4202 AS Manufacturer, mt_Inventory.I4203 AS [Model Number], mt_Inventory.I4204 AS Description, mt_Inventory.Room, mt_Inventory.Location, mt_Inventory.I4218 AS Dept
    FROM mt_Inventory
    WITH OWNERACCESS OPTION;


    IDOverride is part of the table, HOWEVER, I'm thinking the reason why it's not showing that subreport is because there's null values. There are some values under IDOverride, but there not all filled out.

    So I thought something like =IIf(IsNull([IDOverride]),[I4201],[IDOverride]) would work in the criteria. But that failed too.

    Thanks for the help

  2. #2
    54.69.6d.20 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2012
    Posts
    21
    Update: Tried this and it doesn't work. For some reason the sub report will disappear from the Report if I make any changes. I've attached some screen shots to get a better idea.
    SELECT mt_Inventory.I4206 AS SerialNumber, Nz(mt_Inventory.IDOverride, mt_Inventory.I4201) AS CustomerID, mt_Inventory.I4202 AS Manufacturer, mt_Inventory.I4203 AS [Model Number], mt_Inventory.I4204 AS Description, mt_Inventory.Room, mt_Inventory.Location, mt_Inventory.I4218 AS Dept
    FROM mt_Inventory
    WITH OWNERACCESS OPTION;
    Click image for larger version. 

Name:	BeforeChange.png 
Views:	7 
Size:	27.5 KB 
ID:	9103Click image for larger version. 

Name:	AfterChange.png 
Views:	7 
Size:	25.0 KB 
ID:	9104

  3. #3
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Try this -

    Create a new query, go to SQL view, and paste in that SQL. Does it work, i.e. give you the expected results?

    In your report, how do you limit which records the sub-report prints, since the SQL you have contains no criteria?

    John





    (Do you need the OWNERACCESS option? It's only used if you are implementing security-enabled workgroups.)

  4. #4
    54.69.6d.20 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2012
    Posts
    21
    Yes, I'm getting the results I'm looking for creating a new query, however, it's still disappearing after inserting the code in the sub-report.

    What do you mean by "limit which records the sub-report prints"? LinkMasterFields and LinkChildFields properties??

  5. #5
    54.69.6d.20 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2012
    Posts
    21
    Quote Originally Posted by 54.69.6d.20 View Post
    Yes, I'm getting the results I'm looking for creating a new query, however, it's still disappearing after inserting the code in the sub-report.

    What do you mean by "limit which records the sub-report prints"? LinkMasterFields and LinkChildFields properties??
    Looks like I'll have to change the sub report to show another field, because the customerID that I'm changing is what's linking the report to the subreport. Works now. Thanks for your time

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

Similar Threads

  1. If statement in Query
    By Jojojo in forum Queries
    Replies: 5
    Last Post: 11-18-2011, 03:02 PM
  2. Iif Statement in query
    By evanhughes in forum Queries
    Replies: 1
    Last Post: 11-03-2011, 08:55 AM
  3. Query (if Statement I Think?)
    By Hello World in forum Queries
    Replies: 3
    Last Post: 10-13-2011, 09:25 AM
  4. query iif statement help
    By swat in forum Queries
    Replies: 4
    Last Post: 09-30-2011, 11:48 AM
  5. Replies: 7
    Last Post: 08-17-2011, 01:49 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