Results 1 to 10 of 10
  1. #1
    jaffar2000 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2012
    Posts
    11

    ADO Connection to Access from Excel

    Hi all,
    Appreciate your help with this one:
    Established the connection to access2007 but having error message "run time error 3265 item could not be found in the collection corresponding to the requested name or ordinal".
    Why can't it find the relevant fields?
    Here is my code:

    Sub CopyDataFromExcelToAccess()
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset

    Set cn = New ADODB.Connection
    cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\MyFolder\Requests.accdb;Persist Security Info=False;"
    cn.Open
    Set rs = New ADODB.Recordset
    rs.Open "Requests", cn, adOpenKeyset, adLockOptimistic, adCmdTable

    With rs
    .AddNew
    .Fields(rdate) = Sheets("form").Range("H4")
    .Fields(requested_by) = Sheets("form").Range("B4")
    .Fields(Description) = Sheets("form").Range("B11")
    .Fields(department) = Sheets("form").Range("D4")
    .Update
    End With
    rs.Close
    Set rs = Nothing


    cn.Close
    Set cn = Nothing
    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Did you forget the leading period?

  3. #3
    jaffar2000 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2012
    Posts
    11
    No. the leading period exist in the original code...I just dropped it here by mistake.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are you running this from Excel?

  5. #5
    jaffar2000 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2012
    Posts
    11
    Yes. Running from Excel2010 to Access2007.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'm not versed in ADO but can you run this Access db on its own?

  7. #7
    jaffar2000 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2012
    Posts
    11
    The access file itself is working.
    The general idea i'm aiming to is this:
    I have users filling data in excel template file I created for them.
    Each time they are using the excel file they fill the same data in the same cells.
    The access file is my backend where i want to see all the raw data and that is why I need this connection to work.

    Any ideas for a solution?

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    As I said I'm not versed in ADO. I changed your subject to hopefully attract some ADO experts.

  9. #9
    jaffar2000 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2012
    Posts
    11
    No need. Issue solved.
    The system was expecting the field name as a string, so had to write it as:
    .Fields("rdate") = ...

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Excellent! Thanks for post back with your solution.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. vb.net to access connection HELP
    By timosilver in forum Programming
    Replies: 5
    Last Post: 02-26-2012, 12:54 PM
  2. Query to find and COMBINE rows based on 2 fields
    By admessing in forum Queries
    Replies: 2
    Last Post: 12-13-2011, 12:59 PM
  3. Using if to find blank fields?
    By newtoAccess in forum Queries
    Replies: 4
    Last Post: 03-20-2011, 10:48 AM
  4. DAO Recordset Connection for Access 2002
    By creativefusion in forum Programming
    Replies: 5
    Last Post: 08-17-2010, 06:45 PM
  5. Add fields and find percentage
    By gurp99 in forum Queries
    Replies: 1
    Last Post: 08-09-2010, 03:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums