query confustion

pdbowling

Registered User.
Local time
Today, 14:00
Joined
Feb 14, 2003
Messages
179
I've got a table

Dept_Info

ID...........Dept.........DeptGroup.....Station
IA702.....PC............Plant 1...........N1
MA702....PC............Plant 1...........S1
IP000.....PT.............Paint..............P1
etc...

and a query (Costs) that returns

DeptGroup......month
Plant 1............value
Paint...............value
etc...

I run this query:

Select distinctRow(Costs.DeptGroup), [Dept_Info].[Dept], Costs.Value
FROM Costs left JOIN [Dept_Info] on Costs.DeptGroup = [Dept_Info].[DeptGroup];

I get

DeptGroup.....Dept....Value
Plant 1...........PC.......Value
Plant 1...........PC.......Value repeated
Paint..............PT........Value
etc...

Can I get this to be

Plant 1......PC.......Value
Paint.........PT........Value
etc...

no repeats......??????

I've turned myself in circles on this one. If you want to know 'Why' I need to do this.. just ask...
Thanks
PB
 
In the query properties select unique Values to YES.
 
That sounds great but unfortunately, I failed to mention that I am executing the query in VBA and also outputting to Excel. There is no drop down box for it. Is there a class method that I could add that would do the same type of thing? Below are the default methods generated.

With .ActiveSheet.QueryTables.Add( ..code..
query )
.Name = "myQuery"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = False
.RefreshStyle = xlOverwriteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With

If not it's all good. I'll see if I can come at it from a different direction and customize what I have to work with.
PB
 
Closing thread:

WIll post elsewhere. Thanks everyone.
PB
 

Users who are viewing this thread

Back
Top Bottom