Excel-VBA, MS Access with INNER JOIN

luffy88

New Member
Joined
Feb 13, 2017
Messages
8
Hello,
I have a problem with importing data from ms access to excel with <acronym title="visual basic for applications">VBA</acronym>. I use "ADO Connection" to connect excel with acces.
I have 2 tables in ms access. I want to get the newest comment from table p_comment for products. I tried it with inner join, but i get all comments.
so how can i get only the newest/latest comment for a product?
thank you for your help.

sql= "SELECT p_comment.ID, p_comment.p_id, p_comment.user, p_comment.comment, p_comment.c_date FROM product INNER JOIN p_comment ON product.ID = p_comment.p_id"




p_comment
IDp_idusercommentc_date
11test usertest comment19.02.2017
21test123comment119.02.2017
32test1comment319.02.2017
42test1234commen419.02.2017

<tbody>
</tbody>


product:
IDp_namep_datep_desc
1test01.02.2017test
2hallo01.02.2017test

<tbody>
</tbody>
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,545
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top