• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Writing the value of a Named Range to Access table

David Evans

Active Member
I'm able to write the values of cells addressed Rows/Nos to a table with no issue, however my code to write the values from named ranges to a table don't work but don't produce any errors - what am I missing?

Here's a snippet of the code - each of the Ranges referenced is a named range in the Workbook.
Code:
Set rs2 = New ADODB.Recordset
    rs2.Open "FamilyData", cn, adOpenKeyset, adLockOptimistic, adCmdTable
  
    With rs2
        .AddNew
        .Fields("Family") = Range("Relationship_Name").Value
        .Fields("Model") = Range("Model_Name").Value
        .Fields("DateStamp") = Range("DateTimeStamp").Value
        .Fields("Fund_Count") = Range("Fund_Count").Value
        .Fields("AllInc<MF_Count") = Range("AllInlessMF_Count").Value
        .Update
      
    ' all records in a table
    End With
 
Last edited:
I decided to refer to them by their cell references and it worked - occasionally I can be too elegante for my own good .... :confused::awesome:
 
David,

Did the Named Formula include the headers ?

They're not coming from Tables - they were just single cell named ranges. It works fine with a regular reference (Range("A2") but not the named range assigned to A2 ... Range("Named_Range")
 
Did you try:
.Fields("Family") = Range("Relationship_Name").Text

or
.Fields("Family") = Range("Relationship_Name").Value2

etc
 
Did you try:
.Fields("Family") = Range("Relationship_Name").Text

or
.Fields("Family") = Range("Relationship_Name").Value2

etc
No - I did not try .Text or .Value - I just went back to the Cell References in place of the range names, with Worksheets("Sheetname").Range("A3").Value

The process is currently running and I shall see in the am if it has written - it appeared to work on a small sample earlier today ...

Thanks again for you responses - appreciated!
 
Back
Top