Link to home
Start Free TrialLog in
Avatar of dommac82
dommac82

asked on

Error when code runs

Hi Experts,

Thank you for your time and effort.

The code below is attached to a command button. I have used similar code before and it has worked.
In fact when I created the code last week it was working. Now for some reason I get an error message: "You cancelled the previous operation".

Any thoughts


Private Sub Location_by_Variety_by_Age_Report_Click()
On Error GoTo Err_Location_by_Variety_by_Age_Report_Click
 
    Dim LVAqry As String
    Dim LVArpt As String
    
    LVAqry = "Blueberry Location by Variety by Age Report Query"
    DoCmd.OpenQuery LVAqry, acViewNormal, acReadOnly
    
    LVArpt = "Blueberry Location by Variety by Age Report"
    DoCmd.OpenReport LVArpt, acPreview
 
 
Exit_Location_by_Variety_by_Age_Report_Click:
    Exit Sub
 
Err_Location_by_Variety_by_Age_Report_Click:
    MsgBox Err.Description
    Resume Exit_Location_by_Variety_by_Age_Report_Click
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dommac82
dommac82

ASKER

Thanks for your example MX. I removed the On error line and re ran the code; this brought up the debugger, which highlighted the DoCmd.OpenQuery line, so I checked the query and there was an error in a calculation that was preventing it from running.
"Grade:  A - "Thanks for your example MX. I removed the On error line and re ran the code; this brought up the debugger, which highlighted the DoCmd.OpenQuery line, so I checked the query and there was an error in a calculation that was preventing it from running."  "

Yep ... another perfect example of how you can get that error.  Thanks for posting the result ... appreciate that.

mx
You really deserve you rank