Il tuo suggerimento di creare una query al volo mi ha spalancato un mondo. Ho scoperto l'oggetto queryDef e ho fatto una semplice prova:
In questo modo posso crearmi la query al volo e, nel caso esista già, cancellarla per non incorrere in errori. Adesso vedo di sfruttare questa tecnica per alcune cosine.codice:Private Sub Comando0_Click() Dim dbs As Database Dim strSQL As String Dim strQueryName As String Dim qryDef As QueryDef Set dbs = CurrentDb strQueryName = "TempQuery" For Each qryDef In CurrentDb.QueryDefs If qryDef.Name = strQueryName Then CurrentDb.QueryDefs.Delete (strQueryName) Next strSQL = "SELECT * from nomi" Set qryDef = dbs.CreateQueryDef(strQueryName, strSQL) DoCmd.OpenQuery strQueryName, acViewNormal, acReadOnly End Sub
Grazie mille Mister.![]()

Rispondi quotando