Solución final en base a la idea que me ha dado @gbianchi: Private Function filteredQuery() As String Dim sql_ As String Dim divisionSelected_ As Boolean = False Dim areaSelected_ As Boolean = False Dim paisSelected_ As Boolean = False Dim versionSelected_ As Boolean = False Dim mesSelected_ As Boolean = False Dim anioFiscalSelected_ As Boolean = False Dim counter_ As Integer = 0 If Cb_Divisiones.Text <> "" Then divisionSelected_ = True counter_ += 1 End If If Cb_Area.Text <> "" Then areaSelected_ = True counter_ += 1 End If If Cb_Paises.Text <> "" Then paisSelected_ = True counter_ += 1 End If If Cb_Versiones.Text <> "" Then versionSelected_ = True counter_ += 1 End If If Cb_Mes.Text <> "" Then mesSelected_ = True counter_ += 1 End If If Cb_AnioFiscal.Text <> "" Then anioFiscalSelected_ = True counter_ += 1 End If sql_ = filteredQuery2(divisionSelected_, areaSelected_, paisSelected_, versionSelected_, mesSelected_, anioFiscalSelected_, counter_) Return sql_ End Function Private Function filteredQuery2(divisionSelected_ As Boolean, areaSelected_ As Boolean, paisSelected_ As Boolean, _ versionSelected_ As Boolean, mesSelected_ As Boolean, anioFiscalSelected_ As Boolean, counter_ As Integer) Dim sql_ As String = "SELECT * FROM Registros WHERE " If Cb_Divisiones.Text <> "" Then sql_ += "Division = '" & Cb_Divisiones.Text & "' AND " End If If Cb_Area.Text <> "" Then sql_ += "Area = '" & Cb_Area.Text & "' AND " End If If Cb_Paises.Text <> "" Then sql_ += "Pais = '" & Cb_Paises.Text & "' AND " End If If Cb_Versiones.Text <> "" Then sql_ += "Version = '" & Cb_Versiones.Text & "' AND " End If If Cb_Mes.Text <> "" Then sql_ += "Mes = '" & Cb_Mes.Text & "' AND " End If If Cb_AnioFiscal.Text <> "" Then sql_ += "AnioFiscal = '" & Cb_AnioFiscal.Text & "' AND " End If 'End If sql_ += "Enabled = '" & True & "'" Return sql_ End Function Gracias por la ayuda!!