Doing queries in VBA

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Pretty simple question. Does anyone have a simple example for retrieving
data from a table in Access using VBA? I realize there are functions which
let you do different things with table data, metadata, etc. What I am
looking for is a simple example for how you would execute a SQL statement in
a VBA module. I'll give an example:

select count(*) from table1 where buyDate > '06/01/2005'

So, how would I execute the above statement so that I could set a variable
in my module equal to the result? I have read about DAO and ADO, but they
both seem like overkill for a query in the Access project containing the
table I am interested in. Thanks in advance.
.



Relevant Pages

  • Re: dbs.Execute strSQL error - Too few parameters
    ... executing an update SQL statement in VBA. ... SQL executed with Execute goes straight to Jet without the advantage of the ... What is easier though is to delimit the statement so that the form reference ...
    (comp.databases.ms-access)
  • Re: dbs.Execute strSQL error - Too few parameters
    ... executing an update SQL statement in VBA. ... SQL executed with Execute goes straight to Jet without the advantage of the ... What is easier though is to delimit the statement so that the form reference ...
    (comp.databases.ms-access)
  • Re: Doing queries in VBA
    ... you don't run Select queries in VBA. ... > Doug Steele, Microsoft Access MVP ... >> looking for is a simple example for how you would execute a SQL statement ... >> a VBA module. ...
    (microsoft.public.access.modulesdaovba)
  • SQL Error
    ... execute in VBA. ... This SQL statement was generated by the 'Design Query' ...
    (microsoft.public.access.queries)
  • Re: PC Word Macro Not Working in Mac Word
    ... The Mac VBA Editor is a savagely-castrated shadow of the one in Word ... let the Macro Recorder write the bulk of the code for you. ... The "execute" seems to be ... Since, in VBA, we are running within the context of a single application, we ...
    (microsoft.public.mac.office.word)