Jone said:
Can anybody refer me to a web site where I can learn to write quires
in VBA, if I’m not mistaking its called SQL?
One way to learn is to mock up a query in the normal Access query designer.
Then switch to SQL View (View menu), and you have a sample of the statement
you need in your VBA code.
That's not only a good way to learn: it's something I still do after years
of working with Access. In fact, I then use this utility to copy the SQL
into code:
Copy SQL statement from query to VBA
at:
http://allenbrowne.com/ser-71.html
As a basic example of SQL syntax, this query returns 3 fields from 1 table,
applies criteria, and sorts the results:
SELECT CompanyID, Company, City
FROM Table1
WHERE (City = "Springfield")
ORDER BY Company;
The clauses must be in the right order.
Line endings and brackets are optional.
If you want to get serious about learning SQL, get "SQL Queries for Mere
Mortals" by Michael J. Hernandez and John L. Viescas :
http://www.amazon.com/SQL-Queries-Mere-Mortals-Hands/dp/0201433362