"OpenForm was cancelled" followed by app "going away" (looping?)

M

Maury Markowitz

In order to improve performance of my Access application I do not bind forms
to data sources directly, but set them up, with filters, in the Form_Open
events. I use this throughout my app, and it really improves the snappyness
of just about everything.

One form is only usable if the data has particular properties. So after
looking the data up, I check if it is appropriate and then cancel the form if
it's not. Here is the code (Access is locked up, I have to copy this by
hand)...

if rstOrder.recordCount = 1 then
msgbox "There is only one line on this order, no need to calculate a
total."
Cancel = true
Exit sub
end if

When this code runs I get an error _outside_ the Form_Open, "OpenForm was
cancelled..." The dialog allows me to press "Ok". When you do, Access appears
to go into some sort of tight loop, and I have to force quit.

Adding to the confusion is the problem that I cannot seem to step into the
Form_Open. Single-stepping in pops up the error without going into the
Form_Open, and setting breakpoints inside the code does nothing.

Finally, if the rstOrder DOES have more than one line, it works fine. So
something is wrong inside these lines, but I can't imagine what. Is there
some sort of ordering to the lines that is important?

Any ideas?

Maury
 
M

Maury Markowitz

SteveM said:
Why not do your test before trying to open the form?

Two reasons:

1) I'd have to run potentially expensive queries twice
2) I export complex logic around the app

Maury
 
S

SteveM

Would a DCount() really be too expensive?

Using an unbound method for your forms can give you a little more control
over some things but it really negates the power of Access as a development
tool, at least for mdb/mde.

Steve
 
Top