azhar2006,
Again we have trouble understanding your intent. Here is one example (air code - untested) of putting sql in a variable.
I doubt that this is what you are looking for.
Code:
'sample showing SQL in MyVariable
' Get info about Employees that do NOT have duplicate Name in Table Master
....
Dim myVariable as string
MyVariable = "In (SELECT [name] FROM [master] As Tmp GROUP BY [name] HAVING Count (*)> 1)"
Dim mySql as string
MySql = "SELECT EmployeeID, EmployeeNumber, EmployeeName, EmpEmail FROM MyTable " _
& "WHERE EmployeeName "
Dim db as DAO.Database
Dim rs as DAO.Recordset
Set db = currentdb
set rs = db.OpenRecordset( MySql & " NOT " & MyVariable)
With rs
Do While not .eof
Debug.Print !EmployeeID & " " & !EmployeeNumber & " " & EmployeeName & " " &EmployeeEmail
.Movenext
Loop
End With
......