Elpico wrote:
Hi all,
I've got my regular query which I normally run from the Queries window
in Access. However, I'd like to run the sql query from a form I've
written in VB. The problem is the query itself accesses another query
- Is there a way to call a query from within another query using VB -
I keep getting errors when I try to run it.
It looks something like this:
select fieldname1, fieldname2 INTO mytableA
from [my_query];
And my_query goes like this
select [fieldname1].[mytableB], mytableC.*
from mytableB, mytableC
Any idea how I could run this as a query in a vb class?
Thanks,
e.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
First off, your 2nd qry is incorrect. You have a column designator
before a table designator. The qry should be like this:
select mytableB.[fieldname1], mytableC.*
from mytableB, mytableC
You can run a query in VB using the OpenQuery method of the DoCmd
object. E.g.:
DoCmd.OpenQuery "my_Query"
For an action query, which is what an INSERT INTO query is, it is
usually better to use this:
Dim db As DAO.Database
Set db = CurrentDb
db.Execute "my_Query", dbFailOnError
That way you can catch any errors that occur when the query runs.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQiOT04echKqOuFEgEQJHSgCfftaMdEKDBVke12fPS7ioje 8dPlEAnR5P
xbmIPBJCTxoV5HItAFHwtNJQ
=6vCT
-----END PGP SIGNATURE-----