PDA

View Full Version : [SOLVED] Copy a single field from Access to Excel



paulked
01-15-2018, 01:49 AM
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

paulked
01-15-2018, 02:40 AM
It's working now, sorry, needed to re-boot for some reason!