View Full Version : VBA to pull data from DB
JapanDave
11-29-2011, 10:11 PM
Hey, I am very new to MS Access, but I am reasonably versed in VBA for Excel. Can someone tell me how I would go about pulling data from a DB to Excel.
I have to make an invoice up for customers so it will have a Date sold, product, No. Sold, unit price and the total cost.
So I am trying to pull data from 5 columns in the DB from a specified date to date. Eg, Nov 16th to Dec 15th. On top of that I am trying to pull the previous months invoices grand total in the same fashion, eg, Oct 16th to Nov 15th have that on this months invoice.
I can do the VBA on the excel side, but I have no clue where to start from the DB side.
Any help would be appreciated.
HiTechCoach
11-30-2011, 08:37 AM
I would recommend doing this with an Access report. This is basic stuff for Access with queries and no VBA code.
I actual use Access reports to print Excel data. Microsoft recommends this method when you need more powerful reporting than Excel can handle well.
JapanDave
12-01-2011, 09:11 AM
Unfortunately , this is not so simple for me. VBA seems a much easier way to go. BUT, if I were to go via reports, how would I go about doing something like this?
Cheers
mohanvijay
12-01-2011, 08:45 PM
you can get it by using ADODB Library from Excel VBA
HiTechCoach
12-03-2011, 08:24 PM
Unfortunately , this is not so simple for me. VBA seems a much easier way to go. BUT, if I were to go via reports, how would I go about doing something like this?
Cheers
See if this helps:
Batch Printing (Access 2000 and later) (http://www.hitechcoach.com/index.php?option=com_docman&task=doc_details&gid=18&Itemid=28)
Batch Printing and Save As PDF (Access 2007 and later) (http://www.hitechcoach.com/index.php?option=com_docman&task=doc_details&gid=45&Itemid=28)
Cheers.
JapanDave
12-04-2011, 05:12 PM
Thanks guys for the replies. HiTechCoach, that is a great learning tool, I will have to go through it in more depth when I get some more time.
OK, just one more question about reports. Is it possible to make a reports that have reports within a report. The way I am understanding a report is that you make multiple criteria request to filter out the data you are after. But what happens when you want a whole new set of criteria to to filtered ,but have it on the same report? Can you do that?
Filter out a set of employees from store location A's sales and on the same report filter out a set of employees from location B's sales?
I admit I am going to have to research this more in depth myself.
HiTechCoach
12-04-2011, 08:28 PM
Here are some ways to handle what you want: Report Dialog Examples (http://www.hitechcoach.com/index.php?option=com_docman&task=doc_details&gid=9&Itemid=28)
JapanDave
12-05-2011, 04:35 PM
Thanks HiTechCoach. I have not had time ti check them fully out, but thats looks like a lot of work there. Thanks for the link to your file.
Cheers
Dave
HiTechCoach
12-06-2011, 11:01 PM
Being new to Acess I am sure it looks ike a lot of work but it really is very easy to do.
Welcome to the world of databes development and creating a User Interace (UI). Excel really do not have a lot of tools for UI stuff like Access does with forms, etc.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.