Results 1 to 7 of 7

Thread: ACCESS : Import last saved record of particular Name from access database to excel userform
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jul 2017
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    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




    please help

    Regards
    Manish

  2. #2
    New Member
    Join Date
    Jul 2017
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    my code is : searchstring = "SELECT * FROM Table1 WHERE [Name] = '" & TextBox1.Value & "'"

    Access database tabel1 :
    ID Name Year Address
    1 James 2017 abc
    2 Mike 2016 123
    3 Mike 2017 456
    4 James 2018 789
    5 James 2019 000

    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

  3. #3
    Board Regular
    Join Date
    May 2013
    Posts
    591
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

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

    Use a query to sort the data in the order you require and select from that.
    Last edited by welshgasman; May 11th, 2019 at 04:27 AM.
    Office 2007
    Access novice. Sometimes trying to give something back

  4. #4
    New Member
    Join Date
    Jul 2017
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    How?

  5. #5
    Board Regular
    Join Date
    May 2013
    Posts
    591
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

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

    What do you mean how.?
    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

    Code:
    searchstring = "SELECT * FROM MySortedQuery WHERE [Name] = '" & TextBox1.Value & "'"
    Office 2007
    Access novice. Sometimes trying to give something back

  6. #6
    New Member
    Join Date
    Jul 2017
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    Tried with below code but not working

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

    ID Name Year Address
    1 James 2017 abc
    2 Mike 2016 123
    3 Mike 2017 456
    4 James 2018 789
    5 James 2019 000


    for Mike require below output
    3 Mike 2017 456


    for james require below output in userform text boxes

    5 James 2019 000



    Last edited by manissinha; May 11th, 2019 at 02:27 PM.

  7. #7
    Board Regular
    Join Date
    May 2013
    Posts
    591
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

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

    Syntax is SELECT, then WHERE *then* ORDER

    I would have thought you would need something along the lines of
    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

    Code:
    "SELECT TOP 1 Table1.* FROM Table1  WHERE [Name] = '" & TextBox1.Value & "'"  & " ORDER BY YEAR DESC
    


    Tested via QBE
    Code:
    SELECT TOP 1 Transactions.*, Transactions.Description, Transactions.Date
    FROM Transactions
    WHERE (((Transactions.Description) Like "*208271"))
    ORDER BY Transactions.Date DESC;
    HTH
    Office 2007
    Access novice. Sometimes trying to give something back

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •