473,395 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Reading Access Query as Dataset in Access VBA

2
Hello All!

I am attempting to do something I thought was quite simple. I am trying to read an already-built query, within Access 2003, as a dataset in VBA.

Here is my code:
__________________________________________________ __________
Dim queryName As String
queryName = "PartsRequired"

Dim dbForecast As Database, rsData As Recordset
Set dbForecast = DBEngine.Workspaces(0).Databases(0)
Set rsData = dbForecast.OpenRecordset(queryName, dbOpenTable)
__________________________________________________ __________

The error I'm receiving is:
Run-time error '3219': Invalid operation.

I'm guessing my first problem is the "dbOpenTable" keyword on the last line. Unfortunately, I was unable to find something related to queries.

Can this be done in Access?

Thanks,
Steve
Apr 10 '07 #1
3 5861
pks00
280 Expert 100+
see if this works for you


Dim dbForecast As DAO.Database
Dim rsData As DAO.Recordset

Set dbForecast = currentdb
Set rsData = dbForecast.OpenRecordset(queryName)
Apr 10 '07 #2
SChubb
2
That did it! Thank you very much for your help.

Steve
Apr 10 '07 #3
pks00
280 Expert 100+
Cool, glad to have helped


hey that was my 100th post

:)
Apr 10 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: EMW | last post by:
Hi Is it possible to convert a MDB access database to a XML (sheet/something)? I'm very new with XML, thus I don't know all its possibilities. I'm writing a program for my PDA and since it is...
2
by: cashdeskmac | last post by:
I have a form with 7 datagrids, each on a seperate tabpage and reading from it's own dataTable. I would like to take the first three fields of each row and show them in a listbox (for example, ID,...
1
by: David | last post by:
Hi everyone. I have read every page that Google returns on this topic, but can't find anything that resolves my problem. Basically, I have an Access Database that does a number of different...
12
by: VMI | last post by:
For some reason, the process of retrieving data (about 20 records) from an Access table that has 400K records to a dataTable is taking over 3 mins. to complete. Below is my code to connect to the...
2
by: Chuck Ritzke | last post by:
Hi all, I am getting an intermittant error after uploading a project from my development machine. I click on a link which opens an aspx page that, upon page load, reads a very small amount of...
12
by: Selva Chinnasamy | last post by:
Hi I am using batch commands against Ms-Access and getting an error Message "Characters found after end of SQL statement." String Here is my sql Dim str_screens As String = "Select * from Screens...
6
by: Camper Joe | last post by:
Here's my code: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim db As New SqlConnection Dim strSQL As String = "SELECT * FROM users WHERE strUsername = '" &...
5
by: Omer | last post by:
Hi, I am using C# 2.0 along with MS Access database. All my queries are working perfectly fine, but one inner join query is ocntinously throwing. I ahve tried it both from code and running...
2
by: Aussie Rules | last post by:
Hi, Just learning how to use VB.net and Access databases. I am use to working against a SQL server. I have a Oledb connection to an access database. I have created a query in the access...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.