Consulting

Results 1 to 2 of 2

Thread: Copy a single field from Access to Excel

  1. #1
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location

    Copy a single field from Access to Excel

    I am successfully using this:

    Sub ReadPaidJobs()
        With CreateObject("ADODB.Recordset")
            .Open "SELECT * FROM PaidJobs", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Sett.Cells(38, 2) & "KKDB.accdb;"
            DBPJ.Range("A2").CopyFromRecordset .DataSource
        End With
    End Sub
    to copy a table from Access to Excel (Office 2016).

    However, if I try to use this:

    Sub ReadPJobNo()
        With CreateObject("ADODB.Recordset")
            .Open "SELECT JobNo FROM PaidJobs", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Sett.Cells(38, 2) & "KKDB.accdb;"
            DBSum.Range("A2").CopyFromRecordset .DataSource
        End With
    End Sub
    to read just the job numbers I don't get anything, no errors or data! All I've changed is the field name instead of the * and the destination.

    Where am I going wrong?

    Best regards

    Paul Ked
    Semper in excretia sumus; solum profundum variat.

  2. #2
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    It's working now, sorry, needed to re-boot for some reason!
    Semper in excretia sumus; solum profundum variat.

Posting Permissions

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