I'm looking to export demographic info to excel from access. This is what I have so far, it just outputs the fullname in A8 and list them all.
I'd like to pull in the cell phone, address, email etc horizontally from A8 to say A9, A10 etc... then the loop will take over for the next record on B8 the next name and then B9 etc...
The way I have it set up now, it pulls the fullname in the loop, I can't seem to get it to pull other data. I've added it to the SQL statement, but I get the error in the loop, if I put it on the next line. The field I'm trying to add is tblMembers.CellPhone
.Range("B" & i).Value = Nz(rsTEST_ONE!tblMembers.CellPhone, "")
D
I'd like to pull in the cell phone, address, email etc horizontally from A8 to say A9, A10 etc... then the loop will take over for the next record on B8 the next name and then B9 etc...
The way I have it set up now, it pulls the fullname in the loop, I can't seem to get it to pull other data. I've added it to the SQL statement, but I get the error in the loop, if I put it on the next line. The field I'm trying to add is tblMembers.CellPhone
.Range("B" & i).Value = Nz(rsTEST_ONE!tblMembers.CellPhone, "")
Code:
Dim xlApp As Excel.Application
Dim xlWkb As Excel.Workbook
Dim xlWks As Excel.Worksheet
Dim i As Integer
Dim SQLTEST_ONE As String
Dim rsTEST_ONE As DAO.Recordset
SQLTEST_ONE = "SELECT TblMembers.LastName, TblMembers.FirstName, TblMembers.Status, [FirstName] & "" "" & [LastName] AS FullName " & _
"FROM TblMembers " & _
"WHERE (((TblMembers.Status) = 'Active')) " & _
"ORDER BY TblMembers.LastName, TblMembers.FirstName;"
Set rsTEST_ONE = CurrentDb.OpenRecordset(SQLTEST_ONE, dbOpenSnapshot)
Set xlApp = New Excel.Application
Set xlWkb = xlApp.Workbooks.Open(CurrentProject.Path & "\Master\TESTINGONE.xlsx")
Set xlWks = xlWkb.Sheets("Oct")
xlApp.Visible = True
i = 8
With xlWks
Do While Not rsTEST_ONE.EOF
.Range("A" & i).Value = Nz(rsTEST_ONE!FullName, "")
i = i + 1
rsTEST_ONE.MoveNext
Loop
End With
D