I have read the help file and several other forums on how to run a Access 2003 VBA code from an Access 2003 Macro, but nothing works.
The VBA code works very well by itself when I execute it.
When I try to create a macro, then either "open a module", or "run code" macro comamnds, the code does not execute.
Access opens the modeule in design view and waits for me to execute it (press execute)
Pls help
Option Compare Database
Option Explicit
'------------------------------------------------------------
' Connex
'
'------------------------------------------------------------
Public Function Connex()
On Error GoTo Connex_Err
DoCmd.SetWarnings False
DoCmd.OpenQuery "300-NON NOT CONNEX ASSET STATUS 81", acViewNormal, acEdit
DoCmd.OpenQuery "301-NON NOT CONNEX ASSET DATA", acViewNormal, acEdit
DoCmd.OpenQuery "302-NON NOT CONNEX SUMMARY", acViewNormal, acEdit
DoCmd.OpenQuery "303-NON NOT CONNEX ASSET DATA ARREARS", acViewNormal, acEdit
DoCmd.OpenQuery "307-NON NOT CONNEX ASSET DATA PORTFOLIO", acViewNormal, acEdit
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "301-NON NOT CONNEX ASSET DETAILS", "C:\Connex.xls", True, ""
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "302-NON NOT CONNEX SUMMARY2", "C:\Connex.xls", True, ""
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "308-NON NOT CONNEX PORTFOLIO SUMMARY", "C:\Connex.xls", True, ""
DoCmd.SetWarnings True
Connex_Exit:
Exit Function
Connex_Err:
MsgBox Error$
Resume Connex_Exit
End Function
The VBA code works very well by itself when I execute it.
When I try to create a macro, then either "open a module", or "run code" macro comamnds, the code does not execute.
Access opens the modeule in design view and waits for me to execute it (press execute)
Pls help
Option Compare Database
Option Explicit
'------------------------------------------------------------
' Connex
'
'------------------------------------------------------------
Public Function Connex()
On Error GoTo Connex_Err
DoCmd.SetWarnings False
DoCmd.OpenQuery "300-NON NOT CONNEX ASSET STATUS 81", acViewNormal, acEdit
DoCmd.OpenQuery "301-NON NOT CONNEX ASSET DATA", acViewNormal, acEdit
DoCmd.OpenQuery "302-NON NOT CONNEX SUMMARY", acViewNormal, acEdit
DoCmd.OpenQuery "303-NON NOT CONNEX ASSET DATA ARREARS", acViewNormal, acEdit
DoCmd.OpenQuery "307-NON NOT CONNEX ASSET DATA PORTFOLIO", acViewNormal, acEdit
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "301-NON NOT CONNEX ASSET DETAILS", "C:\Connex.xls", True, ""
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "302-NON NOT CONNEX SUMMARY2", "C:\Connex.xls", True, ""
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "308-NON NOT CONNEX PORTFOLIO SUMMARY", "C:\Connex.xls", True, ""
DoCmd.SetWarnings True
Connex_Exit:
Exit Function
Connex_Err:
MsgBox Error$
Resume Connex_Exit
End Function