Group by the records in the combo box

Group by the records in the combo box

  
Hi Can anyone tell me How do I group by the attribute that populates the combo box?

Actually it's about two entities Sales and Profit and loss . The products that sold in sales are the attributes that fill the Sales product attribute (combo box) in profit and loss form. I can sale a same product twice.. So when I do so I'm getting the product twice in combo box too but I need to restrict it by grouping. 

You have to group in the query that populates the combo.


Don't forget to add both entities and to group by Sales.ProductId and Product.Name.


Nuno Reis wrote:

You have to group in the query that populates the combo.

 

Don't forget to add both entities and to group by Sales.ProductId and Product.Name.

 I tried but it still populates the non grouped attribute. Please take a look at this oml and guid me please.
See the profit and loss section . In there sales product combox.
 

You're grouping by PL_Per_Unit and TotalPL. Group only by Id/Name.


Because your Sales table includes product name, try a query only with sales info.

Nuno Reis wrote:

You're grouping by PL_Per_Unit and TotalPL. Group only by Id/Name.

 

Because your Sales table includes product name, try a query only with sales info.

 
 I tried that too Nuno. But the problem is , I referred salesId from the sales db to this profit and loss db. So the combo box takes the variable salesId which is different for each sale even when i sell the same product twice. I want sales each sales details in sales db. (If i sell the product 3 times i get 3 record in sales table thats fine,  thats what I need too ). But when I coming to profit and loss , I need only each record for each product. But I dono how to approach this anymore. I hope you understand my need now.

Why is your field associated with SalesId if its name is Product? You should be filtering by ProductId.


Group by ProductId and ProductName. Sum and Average the other values (some of the fields you have in the form make no sense).