473,473 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Need to run my query code from a form

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.
Nov 13 '05 #1
1 1379
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-----
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says...
6
by: ti33m | last post by:
Hi All, I'd like to include a datasheet on my user interface but since I'm starting to run tight on space, I'd like to have a vertically-oriented datasheet (column 1 has labels, column 2 has...
3
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems...
4
by: Bob | last post by:
Hallo, I have to make a web application in Javascript/ASP for tenniscourt reservation (based on Access database). I would like to do everything with one page, because the user must be able to...
0
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional...
6
by: kenshiro | last post by:
Hi All, I'm having a problem with some VBA code in one of my Access 2003 databases. I'm getting the following error when running code behind a command button on a form: "Item not found in this...
8
by: pamelafluente | last post by:
I am beginning aspNet, I know well win apps. Need a simple and schematic code example to start work. This is what I need to accomplish: ---------------------- Given button and a TextBox on a...
0
by: Chuck36963 | last post by:
Hi all, I've been working on a listing problem and I can't figure out how to work it out. I have looked far and wide on the web to find answers, but I'd like other peoples input on my project in...
3
by: pbd22 | last post by:
Hi. I need some help with structuring my query strings. I have a form with a search bar and some links. Each link is a search type (such as "community"). The HREF for the link's anchor looks...
1
by: Donald Calloway | last post by:
I have created a database application that uses a macro, activated by a button click event, that runs a query which returns a recordset consisting of a subset of the matching database record, and...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.