Created
May 29, 2015 21:45
-
-
Save kissmygritts/ec5567b0acc7d487d6b0 to your computer and use it in GitHub Desktop.
Write CSV file from recordset. Used this because N(records) > what access can handle.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub data_output() | |
Dim rs As DAO.Recordset | |
Dim sql As String | |
Dim fso As Object, csv As Object | |
Dim l As String | |
sql = "SELECT z_dev_collars.Diagnoses, tbl_gps_locations.timestamp, tbl_gps_locations.long_x AS geox, tbl_gps_locations.lat_y AS geoy FROM z_dev_collars LEFT JOIN tbl_gps_locations ON z_dev_collars.Collar_Current_ID = tbl_gps_locations.deviceid WHERE (((tbl_gps_locations.timestamp) Is Not Null));" | |
Set rs = CurrentDb.OpenRecordset(sql) | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
Set csv = fso.createtextfile("C:\Users\Mgritts\Documents\collars2.txt") | |
With rs | |
Do Until .EOF | |
l = !Diagnoses & "," & !timestamp & "," & !geox & "," & !geoy & ",DD" | |
csv.writeline l | |
.MoveNext | |
Loop | |
End With | |
rs.Close | |
csv.Close | |
Set fso = Nothing | |
Set csv = Nothing | |
Set rs = Nothing | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment