Darrell-
What are the data types of CustomerID and Group No? If they are numbers, you can ensure a proper JOIN by using Format(CustomerID, "00000") - enough zeros to cover the largest CustomerID or Group No. Doing a plain concatenation might get some bogus joins - for example customer 11 and Group 1 will match customer 1 and group 11. Formatting the numbers before concatenation will give you 0001100001 for the first combo and 0000100011 for the second. Try it and let me know.
SQL Queries for Mere Mortals
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
I know but alas, I did not design the database. The original developer used the combination of the CustomerID and Group No and the database is too highly used to try to redesign at this point.
Darrell-
Is Group No unique? It seems strange that the Pkey of the Customers table isn't just CustomerID. Sounds like a table design issue.
SQL Queries for Mere Mortals
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
I have to join on the CustomerID and the [Group No] because some CustomerID's have multiple [Group No] but not all the groups have payments. The form is for payment adjustments so only the groups that have payments should appear on the form.
That shouldn't happen. I've seen this in Reports because the report engine tries to "optimize" the Record Source based on grouping specs, but I can't remember seeing this happen in a combo box. Try changing the Row Source to this SQL:
SELECT tblCustomersMain.[Group No], tblCustomersMain.[Account Name], tblCustomersMain.[Contact First Name], tblCustomersMain.CustomerID
FROM tblCustomersMain
WHERE (((tblCustomersMain.[Excluded from Payments])=False)) AND
tblCustomersMain.CustomerID & tblCustomersMain.[Group No] IN
(SELECT [Customer ID] & [Group No] FROM tblExpectedTotals)
ORDER BY tblCustomersMain.[Account Name], tblCustomersMain.[Group No];
That's a bit of a kludge because you're joining on two fields, but it should work OK depending on the data types of CustomerID and Group No. Why are you having to join on two fields?
SQL Queries for Mere Mortals
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
The following SQL is a saved query that is the row source for a combo box on a form:
SELECT DISTINCT tblCustomersMain.[Group No], tblCustomersMain.[Account Name], tblCustomersMain.[Contact First Name], tblCustomersMain.CustomerID
FROM tblCustomersMain INNER JOIN tblExpectedTotals ON (tblCustomersMain.CustomerID = tblExpectedTotals.[Customer ID]) AND (tblCustomersMain.[Group No] = tblExpectedTotals.[Group No])
WHERE (((tblCustomersMain.[Excluded from Payments])=False))
ORDER BY tblCustomersMain.[Account Name], tblCustomersMain.[Group No];
When I run the query from the query designer, I get the expected result of only the rows from tblCustomersMain that have a related row in tblExpectedTotals, a total of 294 rows.
However, as the rows source for the combo box, it is returning Group No from tblCustomersMain that do not have a related row in tblExpectedTotals, a total of 330 rows.
Am I missing something? This is Access 2007 on Windows 7 Enterprise.
The information contained in this communication is highly confidential and is intended solely for the use of the individual(s) to whom this communication is directed. If you are not the intended recipient, you are hereby notified that any viewing, copying, disclosure or distribution of this information is prohibited. Please notify the sender, by electronic mail or telephone, of any unintended receipt and delete the original message without making any copies.
Blue Cross Blue Shield of Michigan and Blue Care Network of Michigan are nonprofit corporations and independent licensees of the Blue Cross and Blue Shield Association.
The information contained in this communication is highly confidential and is intended solely for the use of the individual(s) to whom this communication is directed. If you are not the intended recipient, you are hereby notified that any viewing, copying, disclosure or distribution of this information is prohibited. Please notify the sender, by electronic mail or telephone, of any unintended receipt and delete the original message without making any copies.
Blue Cross Blue Shield of Michigan and Blue Care Network of Michigan are nonprofit corporations and independent licensees of the Blue Cross and Blue Shield Association.
Tidak ada komentar:
Posting Komentar