Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

application development excel - ms access excell

Forum home » Delegate support and help forum » Microsoft Excel Training and help » application development excel - MS Access to Excell

application development excel - MS Access to Excell

ResolvedVersion Standard

Mike has attended:
Excel VBA Intro Intermediate course

MS Access to Excell

Is there a way to import data from Access to Excel using a button on the spreadsheet. i.e. call an Access query and the export facility from Excel.

RE: MS Access to Excell

Hi Mike

Sorry for the delay in getting back to you but our offices have been closed over Christmas. We our now processing all of our forum posts, so we will get back to shortly with an answer for you question.

Thanks

David

RE: MS Access to Excell

try this code
With the procedure below you can import data from an Access table to a worksheet.
Sub ADOImportFromAccessTable(DBFullName As String, _
TableName As String, TargetRange As Range)
' Example: ADOImportFromAccessTable "C:\FolderName\DataBaseName.mdb", _
"TableName", Range("C1")
Dim cn As ADODB.Connection, rs As ADODB.Recordset, intColIndex As Integer
Set TargetRange = TargetRange.Cells(1, 1)
' open the database
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
DBFullName & ";"
Set rs = New ADODB.Recordset
With rs
' open the recordset
.Open TableName, cn, adOpenStatic, adLockOptimistic, adCmdTable
' all records
'.Open "SELECT * FROM " & TableName & _
" WHERE [FieldName] = 'MyCriteria'", cn, , , adCmdText
' filter records

RS2WS rs, TargetRange ' write data from the recordset to the worksheet

' ' optional approach for Excel 2000 or later (RS2WS is not necessary)
' For intColIndex = 0 To rs.Fields.Count - 1 ' the field names
' TargetRange.Offset(0, intColIndex).Value = rs.Fields(intColIndex).Name
' Next
' TargetRange.Offset(1, 0).CopyFromRecordset rs ' the recordset data

End With
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub

Excel tip:

Change Excel's default font

You can change the default font and font size for all spreadsheets created in Excel by:

1. Going to Tools on the menu bar.
2. Select Options, then General.
3. Next to Standard Font you can change the font and font size.
4. Click OK.

Each new file you start from this point onward should use the font and font size you have selected.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.