Access Report Crash on Running Macro

M

MPDog

I have developed a form that passes parameters through to a report. I am
trying to get this form to apply a filter to the report data using an Option
Group.

I have developed a Macro that will, based on a condition statement for the 5
different values of the Option Group, run 1 of 5 different ApplyFilter
actions.

I have this Macro set to run OnActivate for the report. When I run the
report, it opens the selection form, I select the options, click OK, the form
disappears, the report comes up (and is filtered correctly), then 1 or 2
seconds later Access crashes.

Any suggestions?

Thanks,

Marc
 
R

retired fire

Without more info, it is hard to help....Try this:

Add the SingleStep action to the macro, then run it and single step through
the macro to the point of crash. This may narrow down the issue if there is
a problem with the macro....
 
M

MPDog

I have simplified my issue and narrowed it down. I have converted the macro
to VB, and now when I try to run the code from the report to apply a filter,
I still have the problem with Access crashing (no error message given). It
will actually apply the filter, but then I get the crash message directly
after. When I stepinto the code, the point at which it crashes is right when
it runs the "Docmd.ApplyFilter" action. The report changes to show the
filterted data, then access crashes. Any help would be appreciated. Here is
the code:

Function FilterData()
On Error GoTo FilterData_Err

If (Forms![Transactions by Date]!TransactionType = 1) Then
DoCmd.ApplyFilter "", "[Date Range of
Transactions]![Income/Expense]=""Expense"" Or [Date Range of
Transactions]![Income/Expense]=""Income"""
Exit Function
End If
If (Forms![Transactions by Date]!TransactionType = 2) Then
DoCmd.ApplyFilter "", "[Date Range of
Transactions]![Income/Expense]=""Expense"""
Exit Function
End If
If (Forms![Transactions by Date]!TransactionType = 3) Then
DoCmd.ApplyFilter "", "[Date Range of
Transactions]![Income/Expense]=""Income"""
Exit Function
End If
If (Forms![Transactions by Date]!TransactionType = 4) Then
DoCmd.ApplyFilter "", "[Date Range of
Transactions]![Income/Expense]=""Other"""
Exit Function
End If
If (Forms![Transactions by Date]!TransactionType = 5) Then
DoCmd.ApplyFilter "", "[Date Range of Transactions]![Income/Expense]
Like ""*"""
Exit Function
End If


FilterData_Exit:
Exit Function

FilterData_Err:
MsgBox Error$
Resume FilterData_Exit

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top