I'm a bit late to the game but this tutorial looks invaluable to me. I have a fairly complex set of data in an Access database that I need to provide to colleagues that don't have access to the database in Excel format so that they can then build their reports and presentations. I do this alongside my 'day job' which is a maintenance engineer so this video is priceless.
@kolavithonduraski5031 Жыл бұрын
same to me... everything you need to know for pulling data from access... 😊👍 its awesome
@aeththeband5 жыл бұрын
Pure EXCEL-lence. Spent hours trying to find help on this before I came across your video. Your method is the only method I found that has worked so far and it was super easy to implement. THANK YOU SO MUCH.
@F_XVII7 жыл бұрын
This video is such a great tool to use. The code you provided worked great. Instead of SQL I used the code to grab the entire database without qrys. Thank you very much!
@rodmaxwell81823 жыл бұрын
Keep it simple - right!!... Excellent tutorial, just what I needed, thanks a lot!!!
@kolutimehin8 жыл бұрын
This is a very skillful method. Kudos
@jonrasmussen56453 жыл бұрын
Awesome job explaining everything. Thank you!
@giegoar7 жыл бұрын
Works great expect when you use the pivot table, you can't refresh it "RefreshData - UpdateData VBA error: 1004 = We can't change this part of the PivotTable". Any suggestions? Many thanks!
@rangiroa100 Жыл бұрын
Hi Access Jitsu. Is there a way to obtain the VBA code text in a file ? Or you could post the VBA code here. It is really hard to just type them up because the text is so small.
@gregorywilson37152 жыл бұрын
Help! I want to import from access a query into a excel file, to a specific tab and cell
@georgestenning9044 жыл бұрын
How do you get the headers to be transferred across as well?
@ashishsuryawanshi58714 жыл бұрын
Hi Thank you, But it is not working in the server location where only read access is there as I'm only reading the data.
@riadbaziz69304 жыл бұрын
Thank you a lot for this tutorial! At 08:29 how can I Open Database who has a password?
@prathabshivang68964 жыл бұрын
how to create invoice in excel from access database form ????? using vba or macros
@nithiyashreeg75074 жыл бұрын
Hi, Great work. I'm getting "VBA error : unrecognised database format " May I please know how to fix this error?
@EarendilTheBlessed8 жыл бұрын
Thank you for this great tutorial!
@lukefreeman8283 жыл бұрын
oh man... this was brilliant but something incredibly simple would have made it so much more informative for people trying to learn; show us the Access Database you were pulling information from. I have my own .accdb and it would be so easy to know what I need to change if you'd shown us what your original database looked like lol. I also found it kinda weird that you told us a really basic thing like how to make sure dev mode was on and open vba editor etc, but rapidly dropped supporting that basic level of understanding and skipped straight to some seemingly advanced stuff - like what the hell all the SQL stuff was actually doing (this is where seeing the db would have been useful) :( Other than that, really useful video! :D
@t00by00zer2 жыл бұрын
He gave two other examples of code that didn't require the SQL. And they're very easy to use. You can simply copy the entire recordset into an array, do your VBA searches in the array instead of using SQL Here's how I used his code: Public Const dbPath = "C:\Users\yourname\Excel Database Example\YourDB.accdb" Public db As DAO.Database Public rs As DAO.Recordset Sub test() RefreshData ("YourAccessTable") End Sub Sub RefreshData(tbl As String) On Error GoTo err Dim a As Variant, i As Long, j As Integer Application.StatusBar = "Connecting to the Database" Application.Cursor = xlWait Set db = OpenDatabase(dbPath) Set rs = db.OpenRecordset(tbl, dbOpenSnapshot) With rs .MoveLast .MoveFirst ReDim a(1 To rs.RecordCount, 1 To rs.Fields.Count) For i = 1 To .RecordCount For j = 0 To .Fields.Count - 1 a(i, j + 1) = .Fields(j).Value Next j .MoveNext Next i End With etc. The array "a" contains the entire recordset and is easily perused using VBA code for any relationships you want. I chose to use 1 as the starting index so that the array could easily be copied to a range or table.
@josepyoga37907 жыл бұрын
How is writing the script for the Subtotal goods purchased and goods sold. As well as the visible remaining stock. Thank you
@FreeHappiness Жыл бұрын
Can somebody please direct me to the code as the link is not showing the code.
@jillianwilms3 жыл бұрын
very helpful!! Thanks!
@thomasvenus11295 жыл бұрын
Works perfectly. Thank you!
@apbosh14 жыл бұрын
This was so helpful Thank you!
@Griffinbest6 жыл бұрын
This is an amazing tutorial! Thanks so much
@manishsinha74525 жыл бұрын
hi if in access database few data in( tabel1) saved with SAME NAME James but the address is different , I wand to pull the last saved james data not the first , plese suggest the code
@lebeluet8 жыл бұрын
Hi at 5m40s you mention do not use the DAO ref when you are on Excel but use the Microsoft Office xx.x library. Can you elaborate your point of view if the issue is not only releated on the code sample ?
@Accessjitsu8 жыл бұрын
I don't know why I said that now. Looking on the MS website, it looks like the DAO ref would work also. I have not tried it.
@janezklun8 жыл бұрын
Great tutorial, thank you
@JeremyFisher7 жыл бұрын
I want open a PDF file using hyperlink , and i want to specify the file name by a cell value , can you help me please ?
@Thanogr15 жыл бұрын
Great, It shows me object 438 Object Error. As reference i use also DAO object librady
@johndavy38205 жыл бұрын
Great video. Thanks
@noelrobles9606 жыл бұрын
Im so gonna try this at work, thanks
@rickl28348 жыл бұрын
I am currently working on a project where I use VB code in access to do a query and have the SQL variable in a listbox, where I can see all the where conditions on my search. I then want to take that data and export it to an excel spreadsheet. :DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "QueryName", _ "C:\Users\My Computer\Desktop\TRUSTED\Project\Results.xlsx" works fine but I DON'T HAVE A DEFINATIVE QUERY, I HAVE AN SQL VARIABLE. The SQL = "Select...". I want to know how to transferspreadsheet to my desktop with the SQL Varable... is there a way or is there another option?
@Accessjitsu8 жыл бұрын
+Rick L Rick, I don't entirely understand your question. Do you mean you don't have a query that is saved as a database object with your specific criteria saved in it, you only have that in a string variable?
@rickl28348 жыл бұрын
+Access Jitsu I figured out how to do a search using a query that would still show records despite the input being null. Now that I have a query, I can export to excel
@NimishP4 жыл бұрын
How do you open database having password say "ASDF"
@waqqarahad87626 жыл бұрын
Nice work, kindly improve the quality of voice
@spawnyuk7 жыл бұрын
Hi, awesome tutorial, can this code be modified to connect to multiple tables and put the data into the respective worksheet? I have around 24 tables with data that on a single click i want to go into its own Worksheet
@Accessjitsu7 жыл бұрын
Yes! In RefreshData, after executing the query I have there, then you could set the SQL string to a new query and execute it with "Set rs = db.OpenRecordset(SQL, dbOpenSnapshot)" and then loop through rs again putting that data wherever you want it. You could do that as many times as you want.
@spawnyuk7 жыл бұрын
Sorry excuse my ignorance, i'm picking VBA up as i go along so trying to understand this all. Do i create a new SQL string (to store the SQL query) and what else? I have two tables at the moment: tblMasterData (my main source of data) (data goes into tblMasterData worksheet) tblPhase_Stages (lookup column data) (data goes into tblPhase_Stages worksheet) I can inject tblMasterData fine using your technique, but if i want to look at the Phase Stages table, where do i put the xlSheet reference so it goes into the respective worksheet? Currently i have: Set xlSheet = xlBook.Worksheets("tblMasterData") Then it clears the sheet: xlSheet.Range("A2:H1500").ClearContents Then i run my SQL statement: SQL = "SELECT * FROM tblMasterData" Then open my recordset Set rs = db.OpenRecordSet("tblMasterData", dbOpenSnapshot) Then copies to excel: xlSheet.Range("A2").CopyFromRecordSet rs But where do i add in the references to my other table? (tblPhase_Stages) *Just as an FYI, i have around 30 tables in my database, only 24 of those need to be exported to Excel as part of this VBA. The data is being exported into a 'Template' file which they will use to prep data for the re-upload into Access.
@Accessjitsu7 жыл бұрын
Since your openrecordset method is using the table name, you don't need "SQL". After you have written tblMasterData, do this: "Set rs = db.OpenRecordSet("tblPhase_Stages", dbOpenSnapshot)". This replaces the content of rs. Then "Set xlSheet = xlBook.Worksheets("tblPhase_Stages")" I don't know how you are naming your spreadsheet sheets, but you can also use an index to refer to the sheets in the workbook.
@spawnyuk7 жыл бұрын
I've just cracked it, my code could become quite long and maybe isnt the most effective way to do it? ......To check, is the below the best way to execute what i want without any unneeded code? For each table in access, i need to: Set the DAO.Recordset: Dim rs As DAO.Recordset (query for tblMasterData) Dim rs1 As DAO.Recordset (query for tblPhase_Stages) Reference the worksheets: Dim xlSheet = xlBook.Worksheets("tblMasterData") Dim xlSheet2 = xlBook.Worksheets("tblPhase_Stages") Then set the reference to the worksheets: Set xlSheet = xlBook.Worksheets("tblMasterData") Set xlSheet2 = xlBook.Worksheets("tblPhase_Stages") Then clear the worksheets data is going into xlSheet.Range("A2:H1500").ClearContents xlSheet2.Range("A2:H1500").ClearContents Execute the query and populate recordset Set rs = db.OpenRecordset("tblMasterData", dlOpenSnapshot) Set rs1 = db.OpenRecordset("tblPhase_Stages", dlOpenSnapshot) Copy recordset to worksheets: xlSheet.Range("A2").CopyFromRecordset rs xlSheet2.Range("A2").CopyFromRecordset rs1 I also removed the reference to the SQL query as you mentioned, many thanks
@Accessjitsu7 жыл бұрын
That looks good. The only thing I would changes is your Dim statement for xlSheet(s): Dim xlsheet As Excel.Worksheet
@ontheroadagain54028 жыл бұрын
After creating a button using the code provided, when I click on it to import the data, I get a compile error saying Dim db As DAO.Database is an unfound User-defined type. I have activated the MS Access resource in Excel prior to creating the button. I am using Excel 2013 trying to open an Access 2013 database. Any suggestions?
@Accessjitsu8 жыл бұрын
+Anne V. Tschider Yes, when you have the Visual Basic window visible, go to Tools>References and select "Microsoft DAO 3.6 Object Library", then OK.
@ontheroadagain54028 жыл бұрын
+Access Jitsu Thank you. I just checked the 3.6 Object Library, but then I get "Error in loading DLL" after closing the references tool.
@Accessjitsu8 жыл бұрын
+Anne V. Tschider Here is a discussion about your exact situation: www.tek-tips.com/viewthread.cfm?qid=1731794