Hello,
I have code in Excel 2016 that executes a Crosstab query from Access which works well. However, I'm concerned what would happen after I split the database.
Since all the queries will be in the front end, should I reference a read-only copy of the front end where the query is located, or not?
Here is the code:
I have code in Excel 2016 that executes a Crosstab query from Access which works well. However, I'm concerned what would happen after I split the database.
Since all the queries will be in the front end, should I reference a read-only copy of the front end where the query is located, or not?
Here is the code:
Code:
Public Sub GetVariantData()
Dim db As Database
Dim qdf As QueryDef
Dim rs As Recordset
Dim ws As Worksheet
Dim strConnection As String
Dim j As Long
Dim xls As Object 'your Excel.Application with sheet activated
Set ws = ThisWorkbook.Worksheets("SNVs")
Set db = OpenDatabase("C:\Users\Test\UpdataDb.accdb")
Set qdf = db.QueryDefs("graph_variant_final_Crosstab")
Set rs = qdf.OpenRecordset
With ws
For j = 0 To rs.Fields.Count - 1
.Cells(1, j + 1).Value = rs.Fields(j).Name
Next
.Range("A2").CopyFromRecordset rs
End With
rs.Close
'clear memory
Set rs = Nothing
'Enable the screen.
MsgBox "The data has been successfully Imported", vbInformation, "Import successful"
End Sub