Queries are the go because they use the database engine's ability to process the entire data set as a whole. Code with loops is generally far slower because it processes one record at a time. Using loops and cursors is a process derided by database engineers as RBAR, Row By Agonsing Row, spoken "rebar". (Maybe whoever came up with term was also a concreter

)
TSQL does the job of both running queries and what Access does in VBA. It can do loops and cursors (the TSQL equivalent of a recordset) but the queries are usually faster unless you are processing very few records.
Some techniques to avoid RBAR, involve what are known as tally tables. It is a wide subject which you should familairise yourself with if you want to be a great developer. Here is a good example.
Say you have intermittent data but you need to process values for the days in between. The naive developer opens a recordset (cursor) and repeats the processing for the missing days. The knowledgeable developer generates a tally table of all the dates and outer joins it to the data in a query to process it all of it together.
Similar techniques of joining to a tally table are used to parse data instead of looping through it record by record.
The most important concept is that the engine processes whole sets of data at enormous speed. Avoid anything that loops and think of sets of data and you will be on the right track.