Hello All,
I have created Autoexec() in macro to run some set queries qnd export to excel on a daily basis at a scheduled time. Everything was good; Since i could not export this data to excel with date in the file name, i made some changes and now its a big challenge for me.
Here is what i did,
I converted Autoexec macro to Visual basic codes and in the Modules - Converted macro, i made some correction inorder to export the data to excel with date in the file name. But now the problem is when i run the macro from Visual basic editor screeni i am getting the date in the filename but when i run the same macro from access macros screen i am not getting date in the file name. Can some one help me in this.
All i need is to run autoexec macro in a scheduled time and export the data to excel with date in the file name. Please help!!! < i am not very good in VB> kindly help me!!!
here is my vb code
'------------------------------------------------------------
' autoexec
'
'------------------------------------------------------------
Function autoexec()
On Error GoTo autoexec_Err
DoCmd.SetWarnings False
' 0G Toplevel Discrepancy Report
DoCmd.OpenQuery "0G Toplevel Discrepancy Report", acNormal, acReadOnly
DoCmd.OutputTo acOutputQuery, "0G Toplevel Discrepancy Report", acFormatXLS, "L:\HEX\PLNG\Geometric\Daily Reports - DB2\OG Toplevel Discrepancy Report\0G Toplevel Discrepancy Report " & Format(Date, "DDMMMYYYY") & ".xls", , ""
' Contcode Discrepency Report
DoCmd.OpenQuery "Contcode Discrepency Report", acNormal, acReadOnly
DoCmd.OutputTo acOutputQuery, "Contcode Discrepency Report", acFormatXLS, "L:\HEX\PLNG\Geometric\Daily Reports - DB2\Container Code Discrepency\Contcode Discrepency Report " & Format(Date, "DDMMMYYYY") & ".xls", , ""
' Fracz Code Discrepency - Report
DoCmd.OpenQuery "Fracz Code Discrepency - Report", acNormal, acEdit
DoCmd.OutputTo acOutputQuery, "Fracz Code Discrepency - Report", acFormatXLS, "L:\HEX\PLNG\Geometric\Daily Reports - DB2\Frazc code Discrepency\Fracz code Discrepency " & Format(Date, "DDMMMYYYY") & ".xls", , ""
' Time & WSC Discrepency Report
DoCmd.OpenQuery "Time & WSC Discrepency Report", acNormal, acEdit
DoCmd.OutputTo acOutputQuery, "Time & WSC Discrepency Report", acFormatXLS, "L:\HEX\PLNG\Geometric\Daily Reports - DB2\Time & WSC Discrpency\Time & WSC Discrepency Report " & Format(Date, "DDMMMYYYY") & ".xls", , ""
' CAPP+ Cleanup - Next Level Report
DoCmd.OpenQuery "CAPP+ Cleanup - Next Level Report", acNormal, acEdit
DoCmd.OutputTo acOutputQuery, "CAPP+ Cleanup - Next Level Report", acFormatXLS, "L:\HEX\PLNG\Geometric\Daily Reports - DB2\CAPP+ Cleanup - Next Level Report\CAPP+ Cleanup - Next Level Report " & Format(Date, "DDMMMYYYY") & ".xls", , ""
' CAPP+ Cleanup - Attach/Toplevel Report
DoCmd.OpenQuery "CAPP+ Cleanup - Attach/Toplevel Report", acNormal, acEdit
DoCmd.OutputTo acOutputQuery, "CAPP+ Cleanup - Attach/Toplevel Report", acFormatXLS, "L:\HEX\PLNG\Geometric\Daily Reports - DB2\CAPP+ Cleanup - AttachToplevel Report\CAPP+ Cleanup - AttachToplevel Report " & Format(Date, "DDMMMYYYY") & ".xls", , ""
' Opn Nomenclature Discrepancy Report
DoCmd.OpenQuery "Opn Nomenclature Discrepancy Report", acNormal, acEdit
DoCmd.OutputTo acOutputQuery, "Opn Nomenclature Discrepancy Report", acFormatXLS, "L:\HEX\PLNG\Geometric\Daily Reports - DB2\Opn Nomenclature Discrepancy Report\Opn Nomenclature Discrepancy Report " & Format(Date, "DDMMMYYYY") & ".xls", , ""
DoCmd.Quit acSave
autoexec_Exit:
Exit Function
autoexec_Err:
MsgBox Error$
Resume autoexec_Exit
End Function
I have created Autoexec() in macro to run some set queries qnd export to excel on a daily basis at a scheduled time. Everything was good; Since i could not export this data to excel with date in the file name, i made some changes and now its a big challenge for me.
Here is what i did,
I converted Autoexec macro to Visual basic codes and in the Modules - Converted macro, i made some correction inorder to export the data to excel with date in the file name. But now the problem is when i run the macro from Visual basic editor screeni i am getting the date in the filename but when i run the same macro from access macros screen i am not getting date in the file name. Can some one help me in this.
All i need is to run autoexec macro in a scheduled time and export the data to excel with date in the file name. Please help!!! < i am not very good in VB> kindly help me!!!
here is my vb code
'------------------------------------------------------------
' autoexec
'
'------------------------------------------------------------
Function autoexec()
On Error GoTo autoexec_Err
DoCmd.SetWarnings False
' 0G Toplevel Discrepancy Report
DoCmd.OpenQuery "0G Toplevel Discrepancy Report", acNormal, acReadOnly
DoCmd.OutputTo acOutputQuery, "0G Toplevel Discrepancy Report", acFormatXLS, "L:\HEX\PLNG\Geometric\Daily Reports - DB2\OG Toplevel Discrepancy Report\0G Toplevel Discrepancy Report " & Format(Date, "DDMMMYYYY") & ".xls", , ""
' Contcode Discrepency Report
DoCmd.OpenQuery "Contcode Discrepency Report", acNormal, acReadOnly
DoCmd.OutputTo acOutputQuery, "Contcode Discrepency Report", acFormatXLS, "L:\HEX\PLNG\Geometric\Daily Reports - DB2\Container Code Discrepency\Contcode Discrepency Report " & Format(Date, "DDMMMYYYY") & ".xls", , ""
' Fracz Code Discrepency - Report
DoCmd.OpenQuery "Fracz Code Discrepency - Report", acNormal, acEdit
DoCmd.OutputTo acOutputQuery, "Fracz Code Discrepency - Report", acFormatXLS, "L:\HEX\PLNG\Geometric\Daily Reports - DB2\Frazc code Discrepency\Fracz code Discrepency " & Format(Date, "DDMMMYYYY") & ".xls", , ""
' Time & WSC Discrepency Report
DoCmd.OpenQuery "Time & WSC Discrepency Report", acNormal, acEdit
DoCmd.OutputTo acOutputQuery, "Time & WSC Discrepency Report", acFormatXLS, "L:\HEX\PLNG\Geometric\Daily Reports - DB2\Time & WSC Discrpency\Time & WSC Discrepency Report " & Format(Date, "DDMMMYYYY") & ".xls", , ""
' CAPP+ Cleanup - Next Level Report
DoCmd.OpenQuery "CAPP+ Cleanup - Next Level Report", acNormal, acEdit
DoCmd.OutputTo acOutputQuery, "CAPP+ Cleanup - Next Level Report", acFormatXLS, "L:\HEX\PLNG\Geometric\Daily Reports - DB2\CAPP+ Cleanup - Next Level Report\CAPP+ Cleanup - Next Level Report " & Format(Date, "DDMMMYYYY") & ".xls", , ""
' CAPP+ Cleanup - Attach/Toplevel Report
DoCmd.OpenQuery "CAPP+ Cleanup - Attach/Toplevel Report", acNormal, acEdit
DoCmd.OutputTo acOutputQuery, "CAPP+ Cleanup - Attach/Toplevel Report", acFormatXLS, "L:\HEX\PLNG\Geometric\Daily Reports - DB2\CAPP+ Cleanup - AttachToplevel Report\CAPP+ Cleanup - AttachToplevel Report " & Format(Date, "DDMMMYYYY") & ".xls", , ""
' Opn Nomenclature Discrepancy Report
DoCmd.OpenQuery "Opn Nomenclature Discrepancy Report", acNormal, acEdit
DoCmd.OutputTo acOutputQuery, "Opn Nomenclature Discrepancy Report", acFormatXLS, "L:\HEX\PLNG\Geometric\Daily Reports - DB2\Opn Nomenclature Discrepancy Report\Opn Nomenclature Discrepancy Report " & Format(Date, "DDMMMYYYY") & ".xls", , ""
DoCmd.Quit acSave
autoexec_Exit:
Exit Function
autoexec_Err:
MsgBox Error$
Resume autoexec_Exit
End Function