
Originally Posted by
Ajax
assuming fldOrigin is the recordset for the form try
"SELECT DISTINCT " & combo1 & " FROM (" & me.recordsource & ")"
this looks like the right way
however i got the error "the table or query is not found"(something similar)
in immediate window i got
Code:
SELECT DISTINCT Azienda FROM (SELECT Trattative.IDtrattativa, Trattative.CandidatoID, Aziende_1.Azienda AS [Banca candidato], Candidati.nomecognome, Comuni.Comune, Aziende.Azienda, Trattative.StatoTrattativa, Trattative.Fase, Trattative.Manager, Trattative.Nostra, Trattative.[Data inizio trattativa], Trattative.[Data fine trattativa], Trattative.[Head hunter], Trattative.[Ral nuova], Trattative.NumeroCandidatoCliente, Trattative.Note, Candidati.[ptf trasferibile personale] FROM Comuni RIGHT JOIN (Aziende AS Aziende_1 RIGHT JOIN ((Clienti RIGHT JOIN (Candidati INNER JOIN Trattative ON Candidati.IDcandidato = Trattative.CandidatoID) ON Clienti.IDCliente = Trattative.ClienteID) LEFT JOIN Aziende ON Clienti.AziendaID = Aziende.IDazienda) ON Aziende_1.IDazienda = Candidati.AziendaID) ON Comuni.IDComune = Candidati.ComuneID;)
is there any error or i should make a query to have
Code:
SELECT DISTINCT Azienda FROM QUERY
?
EDIT found the problem!
i cannot use me.recordsource cause the form of the filter is not the form i want to filter, so i used "origin" variabile that is the correct recordsource
the problem was the ";" at the end of origin, so i used this and it worked! ùù
Code:
Set ValuesRs = db.OpenRecordset("SELECT DISTINCT " & FldFilt & " FROM (" & Left(Origin, InStr(Origin, ";") - 1) & ");")
THANKS!