dwrpsych128
Registered User.
- Local time
- Today, 13:06
- Joined
- Sep 11, 2013
- Messages
- 11
Good afternoon everyone,
Please bear with me as I a new to macro writing. I'm using Access 2010 macro builder and I cant understand why when I run my macro I get an error box that says: "Microsoft Access Cannot find the name Queries you entered in the expression." I tried running it without the "Queries" part and I get the same message. My code is below:
Option Compare Database
'------------------------------------------------------------
' BurglariesMacro
'
'------------------------------------------------------------
Function BurglariesMacro()
On Error GoTo BurglariesMacro_Err
With CodeContextObject
DoCmd.OpenQuery "BurglariesPast3Days", acViewNormal, acReadOnly
If (.Queries!BurglariesPast3Days!xcoord <> 0) Then
DoCmd.OutputTo acOutputQuery, "BurglariesPast3Days", "ExcelWorkbook(*.xlsx)", "R:\ScratchFolderAutomatedData\BurglariesPast3Days_XYDATA", False, "", , acExportQualityScreen
Else
DoCmd.OutputTo acOutputQuery, "BurglariesPast3Days", "ExcelWorkbook(*.xlsx)", "R:\ScratchFolderAutomatedData\BurglariesPast3Days_GEOCODE", False, "", , acExportQualityScreen
End If
DoCmd.Close acQuery, "BurglariesPast3Days"
End With
BurglariesMacro_Exit:
Exit Function
BurglariesMacro_Err:
MsgBox Error$
Resume BurglariesMacro_Exit
End Function
Please bear with me as I a new to macro writing. I'm using Access 2010 macro builder and I cant understand why when I run my macro I get an error box that says: "Microsoft Access Cannot find the name Queries you entered in the expression." I tried running it without the "Queries" part and I get the same message. My code is below:
Option Compare Database
'------------------------------------------------------------
' BurglariesMacro
'
'------------------------------------------------------------
Function BurglariesMacro()
On Error GoTo BurglariesMacro_Err
With CodeContextObject
DoCmd.OpenQuery "BurglariesPast3Days", acViewNormal, acReadOnly
If (.Queries!BurglariesPast3Days!xcoord <> 0) Then
DoCmd.OutputTo acOutputQuery, "BurglariesPast3Days", "ExcelWorkbook(*.xlsx)", "R:\ScratchFolderAutomatedData\BurglariesPast3Days_XYDATA", False, "", , acExportQualityScreen
Else
DoCmd.OutputTo acOutputQuery, "BurglariesPast3Days", "ExcelWorkbook(*.xlsx)", "R:\ScratchFolderAutomatedData\BurglariesPast3Days_GEOCODE", False, "", , acExportQualityScreen
End If
DoCmd.Close acQuery, "BurglariesPast3Days"
End With
BurglariesMacro_Exit:
Exit Function
BurglariesMacro_Err:
MsgBox Error$
Resume BurglariesMacro_Exit
End Function