A
Adam Clauss
Alright, I've got a table setup that indicates individual purchase orders.
Each purchase order can contain up to 10 line items, so it was decided (long
ago) that the table would have separate columns (item1, item2, ..., item10).
Now, I know this is a horrible way to do it, but this cannot be changed at
this point.
Now, each item has an object code associated with it (object_code1, ...,
object_code10). I now need to perform a summary operation based on grouping
by object codes. So I setup a union query called AllItems that simply
UNION'd the 10 sets of columns together to generate one list of all the
items combined. This query outputs three columns:
account number (that the PO the item came from was for)
object code (the object code associated with that item)
price (the cost of that item)
Good so far?
I also have a table that contains a list of all the object codes (they are
numbers -- stored as strings for use elsewhere) and their descriptions.
So, I created a query ("Summary") which is the following:
SELECT ObjectCodeStrings.object_code_str, ObjectCodeStrings.description,
Sum(AllItems.price) AS total
FROM AllItems INNER JOIN ObjectCodeStrings ON AllItems.object_code =
ObjectCodeStrings.object_code_str
WHERE AllItems.account_number=[Account number:]
GROUP BY ObjectCodeStrings.object_code_str, ObjectCodeStrings.description,
Val([object_code_str]), AllItems.account_number
ORDER BY Val([object_code_str]);
Now, if this query is run WITHOUT the WHERE clause limiting the account
number, it seems to run correctly. I get a list of items, along with valid
object codes and object code descriptions.
However... if I add in that WHERE clause, all of a sudden all my
descriptions show up as the special "box" character that typically indicates
a newline or tab...
That character does not exist in my object code table, so I'm not sure where
that is coming from. Note that the actual object_code_str values are
correct - its just the descriptions that come up incorrect.
Unfortunately... I NEED those descriptions...
Any clues as to why it would do that?
Each purchase order can contain up to 10 line items, so it was decided (long
ago) that the table would have separate columns (item1, item2, ..., item10).
Now, I know this is a horrible way to do it, but this cannot be changed at
this point.
Now, each item has an object code associated with it (object_code1, ...,
object_code10). I now need to perform a summary operation based on grouping
by object codes. So I setup a union query called AllItems that simply
UNION'd the 10 sets of columns together to generate one list of all the
items combined. This query outputs three columns:
account number (that the PO the item came from was for)
object code (the object code associated with that item)
price (the cost of that item)
Good so far?
I also have a table that contains a list of all the object codes (they are
numbers -- stored as strings for use elsewhere) and their descriptions.
So, I created a query ("Summary") which is the following:
SELECT ObjectCodeStrings.object_code_str, ObjectCodeStrings.description,
Sum(AllItems.price) AS total
FROM AllItems INNER JOIN ObjectCodeStrings ON AllItems.object_code =
ObjectCodeStrings.object_code_str
WHERE AllItems.account_number=[Account number:]
GROUP BY ObjectCodeStrings.object_code_str, ObjectCodeStrings.description,
Val([object_code_str]), AllItems.account_number
ORDER BY Val([object_code_str]);
Now, if this query is run WITHOUT the WHERE clause limiting the account
number, it seems to run correctly. I get a list of items, along with valid
object codes and object code descriptions.
However... if I add in that WHERE clause, all of a sudden all my
descriptions show up as the special "box" character that typically indicates
a newline or tab...
That character does not exist in my object code table, so I'm not sure where
that is coming from. Note that the actual object_code_str values are
correct - its just the descriptions that come up incorrect.
Unfortunately... I NEED those descriptions...
Any clues as to why it would do that?