+ Reply to Thread
Results 1 to 15 of 15

Getting access records from excel to fill a listbox

  1. #1
    Registered User
    Join Date
    07-08-2012
    Location
    Venezuela
    MS-Off Ver
    Excel 2010
    Posts
    62

    Getting access records from excel to fill a listbox

    The need: To catch records from two fields of an Access .mdb to fill a listbox directly set into a worksheet. So, a record could be selected to be completely retrived (ie. all its fields)

    The Problem: The code is not working, it returns error messages.

    The Code:

    HTML Code: 
    I certainly thank any help.

    Nelson Calabria

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Getting access records from excel to fill a listbox

    Try this to start

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    07-08-2012
    Location
    Venezuela
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Getting access records from excel to fill a listbox

    Hello Mike,

    I really appreciate you kindness.

    It is not working. It's giving that famouns "System Error 80004005 (-2147467259).

    Still needing help.

    Thank you so much.

    Nelson

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Getting access records from excel to fill a listbox

    Ok, there are all sorts of things potentially going wrong here. Firstly lets try adding the data to an ActiveX listbox, makes things a bit easier. Add it to the page and give it a name. Forget about adding it dynamically for now. Secondly, your Connection string doesn't look right, I think your ThisWorkbook.Path should be outside the string. Thirdly Do you really want the full table in the listbox?

    Try this:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-08-2012
    Location
    Venezuela
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Getting access records from excel to fill a listbox

    Hello Kyle 123,

    Just getting home from work. Thanks for your reply.

    My problem is that I have a workbook with many independent sheets. But when working with any of them I will have to retrive records from a .mdb AccessDB using ADO. Therefore, I need to identify the record to retreive from the values of two (2), at least one (1), fields. I have planned to do that through a listbox to select from, so I have to populate it.

    By the way, you can have the path working without quotes. I have a sub to retreive all the records from a table doing it great with no quotes.

    I hope you could give me a hand to solve my problem.

    Thank you very, very much

    Nelson Calabria

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Getting access records from excel to fill a listbox

    Hi, my code does the same as yours unless I've missed something? It populated a postbox with the entire contents of a given table.

    Did the code not work for you?if not, what was the error and where did it occur?

  7. #7
    Registered User
    Join Date
    07-08-2012
    Location
    Venezuela
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Getting access records from excel to fill a listbox

    Hi, Kyle.

    The error is a System Error &H800004005 (-2147467259)

    My apologies for keeping you busy.

    Thanks,

    Nelson

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Getting access records from excel to fill a listbox

    On which line?

  9. #9
    Registered User
    Join Date
    07-08-2012
    Location
    Venezuela
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Getting access records from excel to fill a listbox

    Hi Kyle,

    I am rookie in the vba world. How can I identify the line were the error comes from?

    Sorry, I did not answered before, right now it is 08:15 am in Venezuela.

    Thanks,

    Nelson

  10. #10
    Registered User
    Join Date
    07-08-2012
    Location
    Venezuela
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Getting access records from excel to fill a listbox

    Hi Kyle,

    I just realized I had a semicolon missed at the very end of the open connection sentence.

    HTML Code: 
    I have the list on the screen, I have no error, but I do not have records retrieved either.

    Thanks,

    Nelson

  11. #11
    Registered User
    Join Date
    07-08-2012
    Location
    Venezuela
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Getting access records from excel to fill a listbox

    Hi Kyle,

    I returned to may code.

    HTML Code: 
    Now I am getting an object required error.

    Nelson

  12. #12
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Getting access records from excel to fill a listbox

    Ok ,I'm confused, did my code work?

    Do you have a Listbox called listbox1 on the sheet?

  13. #13
    Registered User
    Join Date
    07-08-2012
    Location
    Venezuela
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Getting access records from excel to fill a listbox

    No, It did not.

    I have the listbox1 on the sheet when I click a botton to activate the sub, which has this sentence:

    HTML Code: 
    Do you know how to solve that Object Required Error I have when using the last code I sent?

    Thanks,

    Nelson

  14. #14
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Getting access records from excel to fill a listbox

    What was the error with my code?

    You need to say which line it occurs on. At a guess it's because you haven;t fully qualified the listbox ie. Sheet1.Listbox1

  15. #15
    Registered User
    Join Date
    07-08-2012
    Location
    Venezuela
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Getting access records from excel to fill a listbox

    I was in a meeting, sorry.

    The error is: Object Required

    Same as with mine.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1