Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set db = CurrentDb
- 'Check to see if querydef exists
- For i = 0 To (db.QueryDefs.Count - 1)
- If db.QueryDefs(i).Name = "Sheet1" Then
- db.QueryDefs.Delete ("Sheet1")
- Exit For
- End If
- Next i
- Set qd = db.CreateQueryDef("Sheet8", exportSQL)
- 'Set intial filename
- fd.InitialFileName = "export_" & Format(Date, "mmddyyy") & ".csv"
- If fd.Show = True Then
- If Format(fd.SelectedItems(1)) <> vbNullString Then
- DoCmd.TransferText acExportDelim, "Standard Output ", "Sheet1", fd.SelectedItems(1), False
- End If
- End If
- 'Cleanup
- db.QueryDefs.Delete "Sheet1"
- db.Close
- Set db = Nothing
- Set qd = Nothing
- Set fd = Nothing
- End Sub
Add Comment
Please, Sign In to add comment