Append query

  • Thread starter samotek via AccessMonster.com
  • Start date
S

samotek via AccessMonster.com

I have an append query that i want to improve. It is the following:

StrSQL = "INSERT INTO tblObsoleteClients " _
& "SELECT * FROM tblClients " _
& "WHERE Clientid=" & Me.Clientid
CurrentDb.Execute StrSQL, dbFailOnError


However i want to insert only those clients which have the field Obsolete =
True.I have errors in trying to do it. Can you help ?
 
A

Allen Browne

StrSQL = "INSERT INTO tblObsoleteClients " _
& "SELECT * FROM tblClients " _
& "WHERE (Clientid=" & Me.Clientid & ") AND (Obsolete = True);"

One way to learn how to do this is to mock up a query, and switch it to SQL
View. Then in your code, you can add the line:
Debug.Print StrSQL
and when it fails, open the Immeidate Window (Ctrl+G) to compare what you
have to the mock query.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top