Creating simple Query

davesmith202

Employee of Access World
Local time
Today, 14:48
Joined
Jul 20, 2001
Messages
522
I am looking for a simple code snippet for how to create a Query in VBA for Access 2010. I've done it for early versions of Access with DAO etc, although I haven't done this in ages! So, any good examples of a simple query?

I can then modify the code to do what it needs to do!

Thanks,

Dave
 
It doesn't have to be DAO. I understand that Access 2007 and 2010 changed to the newer way of doing things, but I forget the name! I just want to try a query in code, so need an example.

I did start to use one using DAO, but when I went to References to add the DAO, it came up saying DAO error, or something like that.

However, its not important for me to use DAO. Happy to do it the new way!
 
If you show us the exact error you are dealing with, we might be able to help you out. Anyway, I have given the link in Post#2 for using SQL in VBA.

Is that not something you would be interested in?
 
Its on a clients machine, so I don't have access to it for a while.

My apologies on the reference. I glanced through it and saw it was DAO stuff and so thought, that's not what I'm looking for. Then I saw the reference earlier saying that if I am just dealing with Access then ADO is not required and that DAO is better! In which case, I should say, thank you for the appropriate reference.
 
You are most welcome, many programmers prefer DAO over ADODB.

You normally use ADODB when you try connecting to Other Database (MySQL for example) or other Data source (like Excel). DAO is very neat, if you check out THIS LINK, that compares the two you will be able to see what DAO can do..

Good Luck !
 
I used to use DAO before when I did more development, but thought that the ADO was Microsoft's new improved version. Good to know DAO is still hanging in there. :)
 
By default Access uses DAO. ;) Some functionality are too good to be forgotten.
 
A select query is a type of database object that shows information in Datasheet view. A query can get its data from one or more tables, from existing queries, or from a combination of the two.
more detail view
technocrab
 

Users who are viewing this thread

Back
Top Bottom