+ Reply to Thread
Results 1 to 23 of 23

Access database to view in listbox. (file could not founf error)

  1. #1
    Registered User
    Join Date
    07-04-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    38

    Access database to view in listbox. (file could not founf error)

    Hello All,

    Hope you all are doing great.

    This is the code I have added to retrieve data from access to userform listbox
    Where I am getting the error as file could not be found, However my file Path is correct.

    Private Sub Access_to_database()
    'Microsoft ActiveX Data Objects 2.8 Library-Activate
    On Error GoTo UserForm_Initialize_Err
    Dim cnn As New ADODB.Connection
    Dim rst As New ADODB.recordSet
    cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source = E:\SAMI.accdb"
    rst.Open "SELECT (CSTName),(EmailSub) FROM SAMI_Data ORDER BY [EmailSub];", _
    cnn, adOpenStatic

    rst.MoveFirst
    With Summary.Listbox1
    .Clear
    Do
    .AddItem rst![CSTName]
    rst.MoveNext
    Loop Until rst.EOF
    End With
    UserForm_Initialize_Exit:
    On Error Resume Next
    rst.Close
    cnn.Close
    Set rst = Nothing
    Set cnn = Nothing
    Exit Sub
    UserForm_Initialize_Err:
    MsgBox Err.Number & vbCrLf & Err.Description, vbCritical, "Error!"
    Resume UserForm_Initialize_Exit
    End Sub

    It would be really appreciable if any1 can help me on the same.

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Access database to view in listbox. (file could not founf error)

    again please add code tags to your post
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    07-04-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Access database to view in listbox. (file could not founf error)

    Attached Code tag:
    Please Login or Register  to view this content.

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Access database to view in listbox. (file could not founf error)

    Jet doesn't work with accdb file-you need the Microsoft ACE OLEDB 12.0 provider (which you used in your other thread)

  5. #5
    Registered User
    Join Date
    07-04-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Access database to view in listbox. (file could not founf error)

    Hello Sir,

    Thank you for your valuable feedback, I have tried changing the same however I m getting now No Value given for one or more required parameters.

    And its not showing where is the error exactly ....

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Access database to view in listbox. (file could not founf error)

    perhaps
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-04-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Access database to view in listbox. (file could not founf error)

    Hello Sir,

    Thank you so much, you really helped me a lot ,however I want to add another coloumn from access to listbox

    As the CSTname is a coloumn below, I want another coloumn besides it as email sub:

    rst.MoveFirst
    With Summary.Listbox1
    .Clear
    Do
    .AddItem rst![CSTName]
    rst.MoveNext

    Can you please help me with the code to add new coloumn next to cstname as email sub.

    many thanks.

  8. #8
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Access database to view in listbox. (file could not founf error)

    replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    07-04-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Access database to view in listbox. (file could not founf error)

    Yes sir I have already did that in properties, however I need the Coding ....

    Now I m able to view only 1 column in list box i.e(Cstname), where I want email sub also to add besides it.

    I need a code : what will be the next statement which will add after this code

    .AddItem rst![CSTName]

    Many thanks .

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Access database to view in listbox. (file could not founf error)

    please read what I posted-you do not need additem using the code I provided

  11. #11
    Registered User
    Join Date
    07-04-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Access database to view in listbox. (file could not founf error)

    Ok Sir thank you... will check and let you knw....

    Many Many thanks ....

  12. #12
    Registered User
    Join Date
    07-04-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Access database to view in listbox. (file could not founf error)

    Hello Sir,

    There is 1 more code which retrieves data from the access to excel, I feel I have made a small mistake again, which I am not able to recognize at all since last 15 days I m trying to resolve, but dint came upto the mark.

    I m getting an error at Mycon.Open "SAMI"

    Here is the code:
    Please Login or Register  to view this content.
    It will really great if you can help me on the same

  13. #13
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Access database to view in listbox. (file could not founf error)

    what error? your variable is mycn and not mycon by the way
    (option explicit is your friend)

  14. #14
    Registered User
    Join Date
    07-04-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Access database to view in listbox. (file could not founf error)

    Hello sir, it was an typo error, I feel,

    However I m still getting error as ODBC Microsoft access drivers , too few parameters, Expected 5

    and haults error at
    Please Login or Register  to view this content.
    I have checked the table names also from access, they are correct....

    you assistance would be highly appreciable... thanks

  15. #15
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Access database to view in listbox. (file could not founf error)

    you haven't used any table names (and you used mycon not mycn again)

  16. #16
    Registered User
    Join Date
    07-04-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Access database to view in listbox. (file could not founf error)

    Hello sir,

    I have mentioned the table name as well, not able to figure out yet:

    Here goes my revised code:

    HTML Code: 

  17. #17
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Access database to view in listbox. (file could not founf error)

    it helps if you say what's happening ;-)
    perhaps
    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    07-04-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Access database to view in listbox. (file could not founf error)

    My apologies, Pasting error:

    here is the code:

    Please Login or Register  to view this content.
    Thanks.

  19. #19
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Access database to view in listbox. (file could not founf error)

    please try the code I posted

  20. #20
    Registered User
    Join Date
    07-04-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Access database to view in listbox. (file could not founf error)

    Hello Sir,

    that works charm,

    however as you know i have a code which goes from access to excel listbox.

    Now i m worried about how to use hyperlinks to that.

    I dont have any code as i have googled also but cant find anything...

    I want when an user double clicks that data in listbox then it should automatically view alll the data stored in access to the userform controls.

    I mean to say exactly to edit the existing records store in access.

    hope so you will deifinetly help me on the same. as i m not able to create with hyperlink majorly.

    Thanks you so much sir really.

  21. #21
    Registered User
    Join Date
    07-04-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Access database to view in listbox. (file could not founf error)

    Hello Sir,

    really appreciate if you can help me with this issue, seems i m not able to get any code from google.

    Many thanks ....

  22. #22
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Access database to view in listbox. (file could not founf error)

    this thread appears to just keep going from one question to another. please start a new thread for each separate issue

  23. #23
    Registered User
    Join Date
    07-04-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Access database to view in listbox. (file could not founf error)

    ok Sir I have marked this thread as solved, many thanks sir for your kind help..... and i have opened a new thread for my issue. it would be great if you can help me there.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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