How to write action queries using recordset and SQL....

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

I am a newbie in VBA and can someone give me an idea/sample on how to write
action queries like "Add New", "Update" and "Delete", using recordset and
SQL. Thanks
 
Paul said:
I am a newbie in VBA and can someone give me an idea/sample on how to write
action queries like "Add New", "Update" and "Delete", using recordset and
SQL. Thanks

Generally you would use a RecordSet _or_ SQL, with SQL almost always being the
preferred method.

It can be as simple as...

CurrentDB.EXECUTE "SQL Statement", dbFailOnError

"SQL Statement" could be replaced with any valid Append, Update, or Delete query
SQL.

"INSERT INTO SomeTable Field1, Field2,... SELECT Field1, Field2...From
SomeOtherTable"

"UPDATE SomeTable SET SomeTextField = 'SomeValue'"

"DELETE * FROM SomeTable WHERE SomeCriteria"

If in doubt on the SQL you can build the query in the query design grid and then
switch to SQL view and copy that into your code.
 
Back
Top