Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling queries in Access with vba

Status
Not open for further replies.

apple80

Programmer
Aug 4, 2003
1
US
This is my first time writing a Access datbase and vba forms. I am having trouble calling the queries in my database. Can you tell me how to create a connection to the database or if I even need to create a connection since the forms are part of the database. Also can you tell me how to call the queries with and without parameters.
Thanks
 
This is off the top of my head... bear with me.

I think(!) you need to add-in (tools|References) one of the Microsoft data interface libraries (I forget which one-- I've got so much stuff on this machine, I can't remember which one is native to VBA!) and use that to make the connection, which you should be able to do in code, or in the "properties" pane after you drag it on to the form.

Lesson learned while doing what you are doing: Assemble the SQL query first and assign it to a string variable, and then send that variable to the DB (much cleaner).

All of this assumes that you are not accessing the DB with a form made in Access. If you are using Access for the forms, all you need to do is click "Forms" under "objects"(in the child window)in Access, and the connection is made for you.

Hope this helps

-Shrubble
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top