ACCESS : Import last saved record of particular Name from access database to excel userform

manissinha

New Member
Joined
Jul 7, 2017
Messages
9
ZmTm8le
HI

I want to Import last saved record of particular Name from access database to excel userform.

It give me the first record saved for particular name. (FIFO)
I want to import using LIFO method/ code
ZmTm8le




please help

Regards
Manish
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
my code is : searchstring = "SELECT * FROM Table1 WHERE [Name] = '" & TextBox1.Value & "'"

Access database tabel1 :
IDNameYearAddress
1James2017abc
2Mike2016123
3Mike2017456
4James2018789
5James2019000

<tbody>
</tbody>

my code give me first saved "Mike" data year "2016" and address "123"
however i wand last saved "Mike" data , Year "2017" and address "456"

my excel uerform contains Name as Textbox1
Year as Textbox2
Address as Textbox3
search record using Textbox1 by entering name manually
 
Upvote 0
Use a query to sort the data in the order you require and select from that.
 
Last edited:
Upvote 0
What do you mean how.? :confused:
You just create a query, use the GUI if you are not familiar with sql. The you use *that* as your source. So your select would be

Rich (BB code):
searchstring = "SELECT * FROM MySortedQuery WHERE [Name] = '" & TextBox1.Value & "'"
 
Upvote 0
Tried with below code but not working

searchstring = "SELECT * FROM Table1 ORDER BY NAME DESC WHERE [Name] = '" & TextBox1.Value & "'"

IDNameYearAddress
1James2017abc
2Mike2016123
3Mike2017456
4James2018789
5James2019000

<tbody>
</tbody>


for Mike require below output
3Mike2017456

<tbody>
</tbody>


for james require below output in userform text boxes

5 James 2019 000



 
Last edited:
Upvote 0
Syntax is SELECT, then WHERE *then* ORDER

I would have thought you would need something along the lines of
Rich (BB code):
"SELECT * FROM Table1  WHERE [Name] = '" & TextBox1.Value & "'"  & " ORDER BY YEAR DESC

to get all the records. If you are just interested in the one record, then perhaps

Rich (BB code):
"SELECT TOP 1 Table1.* FROM Table1  WHERE [Name] = '" & TextBox1.Value & "'"  & " ORDER BY YEAR DESC


Tested via QBE
Rich (BB code):
SELECT TOP 1 Transactions.*, Transactions.Description, Transactions.Date
FROM Transactions
WHERE (((Transactions.Description) Like "*208271"))
ORDER BY Transactions.Date DESC;

HTH
 
Upvote 0

Forum statistics

Threads
1,213,535
Messages
6,114,192
Members
448,554
Latest member
Gleisner2

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