Results 1 to 6 of 6
  1. #1
    TGirl is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Posts
    2

    Union Query Throwing enter parameter value box

    I am having trouble with my union query because it keeps asking for a parameter value. However, if I click on OK it will go on and show me all the data. Ideas?



    Click image for larger version. 

Name:	EnterParameter.PNG 
Views:	16 
Size:	5.1 KB 
ID:	29759
    Code:
     SELECT dbo_Envio_Product_Sales_ORM.SalesOrderProcessNumber, dbo_Envio_Product_Sales_ORM.CommodityName, dbo_Envio_Product_Sales_ORM.VarietyDesc, dbo_Envio_Product_Sales_ORM.EnteredQuantity, dbo_Envio_Product_Sales_ORM.EnteredPrice, dbo_Envio_Product_Sales_ORM.BillTo_AccountCode, First(Str(Year([ShipOnDate]))) AS [Year], First(Trim(Str(Year([ShipOnDate]))) & "-" & Format(Month([ShipOnDate]),"00")) AS [Month], First(Str(DateValue([ShipOnDate]))) AS [Date], dbo_Envio_Product_Sales_ORM.Pack, dbo_Envio_Product_Sales_ORM.Type, dbo_Envio_Product_Sales_ORM.Size, dbo_Envio_Product_Sales_ORM.SKU, [EnteredQuantity]*[EnteredPrice] AS SalesAmt
    FROM dbo_Envio_Product_Sales_ORM
    GROUP BY dbo_Envio_Product_Sales_ORM.SalesOrderProcessNumber, dbo_Envio_Product_Sales_ORM.CommodityName, dbo_Envio_Product_Sales_ORM.VarietyDesc, dbo_Envio_Product_Sales_ORM.EnteredQuantity, dbo_Envio_Product_Sales_ORM.EnteredPrice, dbo_Envio_Product_Sales_ORM.BillTo_AccountCode, dbo_Envio_Product_Sales_ORM.Pack, dbo_Envio_Product_Sales_ORM.Type, dbo_Envio_Product_Sales_ORM.Size, dbo_Envio_Product_Sales_ORM.SKU, [EnteredQuantity]*[EnteredPrice]
    
    
    UNION 
    
    
    SELECT dbo_Envio_Product_Sales_ORM1.SalesOrderProcessNumber, dbo_Envio_Product_Sales_ORM1.CommodityName, dbo_Envio_Product_Sales_ORM1.VarietyDesc, dbo_Envio_Product_Sales_ORM1.EnteredQuantity, dbo_Envio_Product_Sales_ORM1.EnteredPrice, dbo_Envio_Product_Sales_ORM1.BillTo_AccountCode, First(Str(Year([ShipOnDate]))) AS [Year], First(Trim(Str(Year([ShipOnDate]))) & "-" & Format(Month([ShipOnDate]),"00")) AS [Month], First(Str(DateValue([ShipOnDate]))) AS [Date], dbo_Envio_Product_Sales_ORM1.Pack, dbo_Envio_Product_Sales_ORM1.Type, dbo_Envio_Product_Sales_ORM1.Size, dbo_Envio_Product_Sales_ORM1.SKU, [EnteredQuantity]*[EnteredPrice] AS SalesAmt
    FROM dbo_Envio_Product_Sales_ORM1
    GROUP BY dbo_Envio_Product_Sales_ORM1.SalesOrderProcessNumber, dbo_Envio_Product_Sales_ORM1.CommodityName, dbo_Envio_Product_Sales_ORM1.VarietyDesc, dbo_Envio_Product_Sales_ORM1.EnteredQuantity, dbo_Envio_Product_Sales_ORM1.EnteredPrice, dbo_Envio_Product_Sales_ORM1.BillTo_AccountCode, dbo_Envio_Product_Sales_ORM1.Pack, dbo_Envio_Product_Sales_ORM1.Type, dbo_Envio_Product_Sales_ORM1.Size, dbo_Envio_Product_Sales_ORM1.SKU, [EnteredQuantity]*[EnteredPrice];

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You are using that name, ShipOnDate, but the query doesn't recognize it as a valid field name. It must exist as a field on both tables.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    It's not finding a field called ShipOnDate in either dbo_Envio_Product_Sales_ORM or dbo_Envio_Product_Sales_ORM1. Use Null as placeholder for the table that doesn't have the field.

    Why do you use DateValue() function to make sure ShipOnDate is a date then convert it to a string with Str()? Why convert extracted year to a string?

    Would be wary of using First or Last aggregate functions, maybe you really need Min or Max.

    Year and Date are reserved words. Should not use reserved words as names. Better would be ShipDate and ShipYear.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    TGirl is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Posts
    2
    ShipOnDate is in both the dbo_Envio_Product_Sales_ORM1 and dbo_Envio_Product_Sales_ORM.

    I changed the Date name to ShippedDate and now it has two pop ups. One is the same as before and the other is asking for a date.

    the ShipOnDate field is date and time but I need it to be just the date. What formula would you recommend?



  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Did you change the alias names in both SELECT?

    Only need to specify alias field names in the first SELECT line. Example:

    SELECT field1 AS [somename], field2 AS [anothername] FROM table1
    UNION SELECT field1, field2 FROM table2;

    Why do you have two tables with same kind of data? Why not 1 table? Then would not need UNION.

    DateValue() returns just the date part. Why do you then convert it to a string? Same for the Year extract.

    You might need UNION ALL because just UNION won't allow duplicate records.

    Why the query is not finding ShipOnDate fields is a mystery. I don't know your db to determine cause.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    roaftech is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Nov 2012
    Location
    Romania
    Posts
    65
    Quote Originally Posted by June7 View Post
    ...

    Why the query is not finding ShipOnDate fields is a mystery.
    ...
    One observation that might be relevant ...
    I have spent hours trying to find missing field names, finally discovering that they were mentioned in the "conditional format" spec. Another possibility is in the "grouping and sorting" sub-menu.
    Also applies (where appropriate) to Excel.

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

Similar Threads

  1. Update Query - Enter Parameter Value
    By Evans2 in forum Queries
    Replies: 2
    Last Post: 05-10-2015, 12:22 AM
  2. Replies: 3
    Last Post: 10-23-2014, 04:22 PM
  3. Replies: 5
    Last Post: 02-10-2014, 04:46 PM
  4. ComboBox to Run Query and enter Parameter
    By tristangemus in forum Forms
    Replies: 13
    Last Post: 06-25-2013, 09:54 AM
  5. Replies: 13
    Last Post: 01-10-2012, 09:56 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