HELP!!! why does my macro NOT run

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
 
You are showing VBA , not macro. In Access a macro is not VBA but something different. Repost your question in Module & VBA forum, under a descriptive title.

Your title contains 0 specific information about your issue (99 % of all posts are about help with code that doesn't do what is wanted). Descriptive titles are useful for all readers to find similar problems, among other things in Similar Threads section at the bottom of each thread. See what titles others put on their posts.
 
Not 100% certain, but I think you need to use DLookup to get a value back from a query.
Example: if DLookup("xcoord", "BurglariesPast3Days") > 0 then
 

Users who are viewing this thread

Back
Top Bottom