shabbaranks
Registered User.
- Local time
- Today, 09:57
- Joined
- Oct 17, 2011
- Messages
- 300
Hi guys,
Im trying to get this code to select from a table based on a field and then export. I know I can do it using a query but would like to further my sql and vba knowledge. Can anyone assist please? The code I have currently is
Thanks
Im trying to get this code to select from a table based on a field and then export. I know I can do it using a query but would like to further my sql and vba knowledge. Can anyone assist please? The code I have currently is
Code:
Dim strPasswd
strPasswd = InputBox("Enter Password", "Restricted Form")
If strPasswd = "" Or strPasswd = Empty Then
MsgBox "No Input Provided", vbInformation, "Required Data"
Exit Sub
End If
If strPasswd = "export" Then
DoCmd.RunSQL Mysql = "SELECT TimesheetTable.sUser, TimesheetTable.Activity, TimesheetTable.Hours, TimesheetTable.Project, TimesheetTable.[Task Date] FROM TimesheetTable WHERE (TimesheetTable.Approved)=True;"
DoCmd.OutputTo acOutputQuery, "ExportCSVQuery", "MicrosoftExcel(*.xlsx)", "D:\Test\" & Format(Date, "ddmmyyyy") & ".csv", False, ""
DoCmd.OpenQuery "UpdateExportedQuery"
Else
Thanks