Problem:
I originally had a query that was working great but I'm now having to change it to pull more fields. When I try run the new query it picks a field name and says that I haven't included it as part of the aggregate function. Each time I get this error I can add the field the error specifies to the Group By statement and the error message will choose a new field that isn't included. Anyone have any idea's as to how I can get the same information I was getting with the original query just with more fields?
Description of how query is supposed to work:
The query is meant to pull one record for each distinct set of *readings_miu_id*s and ReadDates (The PremID field is the same for each distinct *readings_miu_id*).
Original Query:
strSql3 = " SELECT Distinct readings_miu_id, ReadDate, PremID " & _
"INTO analyzedCopy2 " & _
"FROM analyzedCopy "
DoCmd.SetWarnings False
DoCmd.RunSQL strSql3
DoCmd.SetWarnings True
New Query:
strSql3 = " SELECT Top 1 readings_miu_id, Reading, ReadDate,Format([MIUtime],'hh:mm:ss') AS ReadTime,MIUwindow,SN,Noise,RSSI,ColRSSI,MIURSSI,Firmware,CFGDate,FreqCorr,Active,MeterType,OriginCol,ColID,Ownage,SiteID,PremID , Neptune_prem.prem_group1, Neptune_prem.prem_group2,ReadID " & _
"INTO analyzedCopy2 " & _
"FROM analyzedCopy " & _
"Group By readings_miu_id, ReadDate, PremID " & _
"Order By readings_miu_id, ReadDate, ReadID, PremID "
DoCmd.SetWarnings False
DoCmd.RunSQL strSql3
DoCmd.SetWarnings True