Access Shuts Down after Me.Form.Requery

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Form1 with a tab control. On one of the tabs there is a Form2a + a
subForm2b. Form2a is based on a query with a permanent criteria filter.
The user performs a function on each of the records displayed by Form2a.
After the user function, the form is requeried using VBA code
(Me.Form.Requery)

The process works great until there is only 1 record remaining. Then the
{Me.Form.Requery} VBA action causes Access to give the obligatory {... going
to shut down...} message and shuts down.

NOTE: If I comment out the {Me.Form.Requery} in the VBA code and execute a
{Remove Filter/Sort} from the {Menu} bar, Access does not shut down.

Does anyone know what is going on here?
I have tried using the DoCmd.RunCommand acCmdRemoveFilterSort in the VBA
code but Access still shuts down.
 
Slator said:
I have a Form1 with a tab control. On one of the tabs there is a
Form2a + a subForm2b. Form2a is based on a query with a permanent
criteria filter. The user performs a function on each of the records
displayed by Form2a. After the user function, the form is requeried
using VBA code (Me.Form.Requery)

The process works great until there is only 1 record remaining. Then
the {Me.Form.Requery} VBA action causes Access to give the obligatory
{... going to shut down...} message and shuts down.

NOTE: If I comment out the {Me.Form.Requery} in the VBA code and
execute a {Remove Filter/Sort} from the {Menu} bar, Access does not
shut down.

Does anyone know what is going on here?
I have tried using the DoCmd.RunCommand acCmdRemoveFilterSort in the
VBA code but Access still shuts down.

Do I gather from your description that the function the user is taking
on these records is changing them such that they no longer meet the
criteria to appear on the form?

Where and in what event is this code to requery the form being executed?

Is the form from which you are (I gather) removing records by this code
nonupdatable? I'm wondering if it has anything to do with the form
becoming totally blank, as they do when there are no records to display
and no records can be added.

Does it make any difference if you execute Me.Requery instead of
Me.Form.Requery? The former is more usual.
 
Q1 Answer = Yes, after the change the record does not meet the criteria.
Q2 Answer = The code is in the form's class module.
Q3 Answer = The form is "technically" updateable, meaning I have set the
properties accordingly for the related objects.
However, I do
not know how to check to see if the form is "really"
updateable,
which is sometimes the case with Access but there is not a
problem as long as the record processing can be resolved
completely
in memory.
Q4 Answer = No, the form will still be displayed with no records to.
NOTE: The form has been working for months prior to
problem.
Q5 Answer = No, Me.Requery and Me.form.Requery produce the same results.
 
Slator said:
Q1 Answer = Yes, after the change the record does not meet the
criteria.
Q2 Answer = The code is in the form's class module.
Q3 Answer = The form is "technically" updateable, meaning I have set
the properties accordingly for the related
objects.
However, I do
not know how to check to see if the form is
"really" updateable,
which is sometimes the case with Access but there
is not a problem as long as the record processing
can be resolved
completely
in memory.
Q4 Answer = No, the form will still be displayed with no records to.
NOTE: The form has been working for months prior
to problem.
Q5 Answer = No, Me.Requery and Me.form.Requery produce the same
results.

Possibly the form has become corrupted somehow. Try decompiling the
database and see if the problem goes away. Here's how:

1. With the database closed -- no users in it at all -- and (ideally)
Access not running, make a backup copy.

2. On the task bar, click Start -> Run...

3. Enter this (adapted match your database path and name) in the Run
dialog box and click OK:

msaccess.exe /decompile "C:\My Documents\YourDBName.mdb"

You may need to include the full path to msaccess.exe, but I don't find
that to be the case when I try it. Depending on your Access version,
you may not get any sign that anything in particular happened. Your
database will probably open in Access.

4. Compact and Repair your database.

5. Open the database again, press Alt+F11 to switch to the VB Editor,
and click Debug -> Compile (your project). If any errors appear, fix
them and recompile.

6. Close the VB Editor. Compact & Repair again.

See if the problem has disappeared.
 
Back
Top