This code can be run from any module within Access.
If you look in the Navigation pane for your query, you will now see that it has an update
icon against it and it has changed its type.
Similarly, you could also change the query to a Delete query:
Sub ChangeQuery()
CurrentDb.QueryDefs("MyNewQuery").SQL = _
"delete * from orders where customer='Customer D'"
Application.RefreshDatabaseWindow
End Sub
In the Navigation pane, notice that your query now has a delete icon against it.
You can also change the ODBCtimeoutproperty in this way. Thetimeoutproperty sets
the time limit when a query will end if no data is received. It can be a problem if you are
using external tables and the external server is running slow (possibly due to the load from
other users). The property value default is set to 60 (60 seconds), but you may wish to
increase it:
Sub SetTimeout()
CurrentDb.QueryDefs("MyNewQuery").ODBCTimeout = 120
End Sub
Chapter 26: Creating and Editing Queries in VBA 295