A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Hey Van, Ken Douglas and others... Need Query help again please...



 
 
Thread Tools Display Modes
  #1  
Old July 11th, 2004, 08:59 AM
Bob M.
external usenet poster
 
Posts: n/a
Default Hey Van, Ken Douglas and others... Need Query help again please...

Hey guys... Thanks so much. Van... I put in your code and it worked.

I HAVE ONE PROBLEM THOUGH.

Below is actual output from query (except frist 2 lines):... problem is
stated after sample data.....

Rec# FileID SS# Lastname Firstname
======|======|========|============|==========
Rec# 20 Fl_u015 229806158 RORER JOHN
Rec# 21 Fl_u015 229806158 RORER JOHN
Rec# 22 Fl_u015 239605327 CRUZ ISMAEL
Rec# 23 Fl_u015 239605327 CRUZ ISMAEL
Rec# 24 Fl_u015 242415467 VANDERHAAR KIRK
Rec# 25 Fl_u015 242415467 VANDERHAAR KIRK
Rec# 26 Fl_u015 254905806 SWAIN BERT
Rec# 27 Fl_u015 254905806 SWAIN BERT
Rec# 28 Fl_u015 261252957 FULLERTON MICHAEL
Rec# 29 Fl_u015 261588101 PEREZ MARGARET
Rec# 30 Fl_u015 261840282 DASH LORRAINE


You will notice that there are duplicate soc sec. numbers until rec# 28.
Upon inspection of the database I was stumped. There is a previos run with
FILEID named fl_u014. The query picked up duplicate ss#'s from the fl_U014
and erroneously populated the recordset with it. I only want duplicate
ss#'s for one particular FILEID (fl_u015) which is hard coded into the SQL
statement at this tiome but will be a varible in the future. I don't know
SQL good enough to figure out what conditional is missing and from where in
the statement.

Here's the code again:

cmd = "SELECT EmployeeSSNumber, REmployee.FileId, " & _
" CompanyID, RecordType, StateCode, " & _
" EmployeeFirstName, EmployeeLastName, QuarterEnding " & _
" FROM REmployee " & _
" WHERE (EmployeeSSNumber In " & _
" ( SELECT [EmployeeSSNumber] FROM [REmployee] As Tmp " & _
" GROUP BY [EmployeeSSNumber] HAVING Count(*)1 ) ) " & _
" AND (FileId= ""Fl_u015"" )" & _
"ORDER BY EmployeeSSNumber"


Thanks again everyone for all your help. ..... BOB



  #2  
Old July 11th, 2004, 07:32 PM
Ken Snell
external usenet poster
 
Posts: n/a
Default Hey Van, Ken Douglas and others... Need Query help again please...

reply posted in original thread.

--

Ken Snell
MS ACCESS MVP

"Bob M." wrote in message
...
Hey guys... Thanks so much. Van... I put in your code and it worked.

I HAVE ONE PROBLEM THOUGH.

Below is actual output from query (except frist 2 lines):... problem is
stated after sample data.....

Rec# FileID SS# Lastname Firstname
======|======|========|============|==========
Rec# 20 Fl_u015 229806158 RORER JOHN
Rec# 21 Fl_u015 229806158 RORER JOHN
Rec# 22 Fl_u015 239605327 CRUZ ISMAEL
Rec# 23 Fl_u015 239605327 CRUZ ISMAEL
Rec# 24 Fl_u015 242415467 VANDERHAAR KIRK
Rec# 25 Fl_u015 242415467 VANDERHAAR KIRK
Rec# 26 Fl_u015 254905806 SWAIN BERT
Rec# 27 Fl_u015 254905806 SWAIN BERT
Rec# 28 Fl_u015 261252957 FULLERTON MICHAEL
Rec# 29 Fl_u015 261588101 PEREZ MARGARET
Rec# 30 Fl_u015 261840282 DASH LORRAINE


You will notice that there are duplicate soc sec. numbers until rec# 28.
Upon inspection of the database I was stumped. There is a previos run

with
FILEID named fl_u014. The query picked up duplicate ss#'s from the

fl_U014
and erroneously populated the recordset with it. I only want duplicate
ss#'s for one particular FILEID (fl_u015) which is hard coded into the SQL
statement at this tiome but will be a varible in the future. I don't know
SQL good enough to figure out what conditional is missing and from where

in
the statement.

Here's the code again:

cmd = "SELECT EmployeeSSNumber, REmployee.FileId, " & _
" CompanyID, RecordType, StateCode, " & _
" EmployeeFirstName, EmployeeLastName, QuarterEnding " & _
" FROM REmployee " & _
" WHERE (EmployeeSSNumber In " & _
" ( SELECT [EmployeeSSNumber] FROM [REmployee] As Tmp " & _
" GROUP BY [EmployeeSSNumber] HAVING Count(*)1 ) ) " & _
" AND (FileId= ""Fl_u015"" )" & _
"ORDER BY EmployeeSSNumber"


Thanks again everyone for all your help. ..... BOB





 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:15 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.