D
Dale Fye
Bob,
Not sure where the problem is, although I think I would preface all of the
fields in the IN clause with the aliased tablename like below. I also
perfer to insert quotes into the string using the chr$(34) function, instead
of using the triple quotes (its just easier for me to read with my bad
eyes).
Another thing you might want to try this.
1. Define a string varaible (strSQL)
2. instead of setting your cmd property equal to the code, set the strSQL
equal to your new code
3. Then, on the next line of code enter: debug.print strSQL
4. Step thru the code using the F8 key, so that the code pauses after the
debug.print operation
4. Copy the SQL string from the debug window and paste it in a query. If
it doesn't work, Access will usually highlight where the flaw is in the
code. Then you can go back, modify the code, move your pointer back to the
statement: strSQL = "Select ...", and step thru it again, copying and
pasting the code from the debug window into your querys SQL until it runs
properly.
HTH
Dale
Not sure where the problem is, although I think I would preface all of the
fields in the IN clause with the aliased tablename like below. I also
perfer to insert quotes into the string using the chr$(34) function, instead
of using the triple quotes (its just easier for me to read with my bad
eyes).
" FROM [REmployee] As Tmp " & _" ( SELECT Tmp.[EmployeeSSNumber] " & _
" HAVING Count(Tmp.*) >1 )) " & _" WHERE Tmp.REmployee.FileId = " & chr$(34) & CurrentFileId & chr$(34) & _
" GROUP BY Tmp.[EmployeeSSNumber] " & _
" AND (REmployee.FileId = " & chr$(34) & CurrentFileId & chr$(34) & " )" & _
"ORDER BY EmployeeSSNumber"
Another thing you might want to try this.
1. Define a string varaible (strSQL)
2. instead of setting your cmd property equal to the code, set the strSQL
equal to your new code
3. Then, on the next line of code enter: debug.print strSQL
4. Step thru the code using the F8 key, so that the code pauses after the
debug.print operation
4. Copy the SQL string from the debug window and paste it in a query. If
it doesn't work, Access will usually highlight where the flaw is in the
code. Then you can go back, modify the code, move your pointer back to the
statement: strSQL = "Select ...", and step thru it again, copying and
pasting the code from the debug window into your querys SQL until it runs
properly.
HTH
Dale
Bob M. said:The big statement at bottom worked when I had FileId = "fl_u015" but when I
put in variable instead it takes forever and instead of a
RECORDSET of 102 records it yeilds 3 records and is not correct.
Any ideas???
Bob M.
' This works in ado properties: as of 7/13/04
' SELECT EmployeeSSNumber, DupRecordFlag, REmployee.FileId, CompanyID,
RecordType, StateCode, EmployeeFirstName, EmployeeLastName, UnitCode,
EmployeeMiddleName, EmployeeNameSuffix, QuarterEnding, EmployeeGrossWages,
EmployeeTaxableWages, UnemploymentTaxAccountNumber FROM REmployee WHERE
(EmployeeSSNumber In ( SELECT [EmployeeSSNumber] FROM [REmployee] As Tmp
WHERE FileId = "Fl_u015" GROUP BY [EmployeeSSNumber] HAVING
Count(*)>1 ) ) AND (FileId= "Fl_u015" ) ORDER BY EmployeeSSNumber
' This is not working correctly: as of 7/13/04
' cmd = "SELECT EmployeeSSNumber, REmployee.FileId, " & _
" CompanyID, RecordType, StateCode, DupRecordFlag, " & _
" UnitCode, EmployeeMiddleName, EmployeeNameSuffix, " & _
" EmployeeFirstName, EmployeeLastName, QuarterEnding, " & _
" EmployeeGrossWages, EmployeeTaxableWages,
UnemploymentTaxAccountNumber" & _
" FROM REmployee " & _
" WHERE (EmployeeSSNumber In " & _
" ( SELECT [EmployeeSSNumber] FROM [REmployee] As Tmp " & _
" WHERE (REmployee.FileId = """ & CurrentFileId & """)" & _
" GROUP BY [EmployeeSSNumber] HAVING Count(*)>1 ) ) " & _
" AND (REmployee.FileId = """ & CurrentFileId & """ )" & _
"ORDER BY EmployeeSSNumber"