do you want to manually import the queries once-off?
if so just right click in the query window, select import and follow
the wizard.
However, if you want to dynamically import the queries using vba, then
this is a different matter. I have situations where sql statements are
stored in another database and imported and saved as local queries as
required. you may want to just use the import method - it's really down
to what you are trying to achieve.
after that it's a matter of learning how to open and loop through
recordsets with vba. there's TONS of great examples out there written
in both ADO and DAO - but this is the kind of thing you are looking for
'Begin aircode----------------
dim rst as dao.recordset
set rst = currentdb.openrecordset("YourQueryName")
if rst.eof then err.raise 1234,,"No Data in recordset"
rst.movefirst
do while not rst.eof
yourVariable1 = rst!QueryFieldName1
yourVariable2 = rst!QueryFieldName2
rst.movenext
loop
rst.close
'End aircode-----------------
On Dec 14, 4:23 pm, "fcolo...@gmail.com" <fcolo...@gmail.comwrote:
Quote:
I'm an experienced Access user, but very new to coding VBA in Access.
I'd like to do the following:
>
1) Develop a basic query in the query designer.
2) Call that query from a VBA script
3) Manipulate the data from the results set in the VBA script (i.e.
read data from fields into variables, etc.)
>
This conceptually seems like it should be an easy thing to do. However,
I'm finding it difficult to find articles or postings on the subject.
>
I'm finding a lot of posting that involves queries that are actually
written in the VBA code. But I don't want the SQL statements in my VBA.
I want them encapsulated.
>
The reason being, I have existing queries from another database. I'd
like to import those queries into my db, and then create VBA scripts to
run and perform analysis on the result set.
>
Can anyone provide a VBA code sample of how I can do this? If it's
complicated to do, and you don't have a sample handy, can you point
me to a good website where I might find one?
>
Thanks.