remove filter on a form when closing

L

LGarcia

Hi All,
I have form "frmRecipes" that can be called from two different places: from
a button on a form named "frmUserRecipes" and from a button on the main
switchboard.

From "frmUserRecipes" I use this code to take me to a specific record:
DoCmd.OpenForm "frmRecipes", acNormal, ,
"FoodCode=Forms!frmUserRecipes!OLDRNUM"
This works fine.

If I use the button on the switchboard I get prompted for
"Forms!frmUserRecipes!OLDRNUM" when "frmRecipes" opens. I need it to open on
the first record in this instance - no filter.

I've added an OnClose event to "frmRecipes" and typed Me.FilterOn = False. I
also tried Me.Filer = "". Both times AX07 gives me an error and shuts down.
I aslo changed "Filter on load" to NO and this also shuts down access.

Can anyone help?
TIA,
LGarcia
 
G

Guest

For the WhereCondition of the OpenForm method concatenate the value of the
control into the expression, rather than referencing it in the literal
string. If FoodCode is a number data type:

"FoodCode=" & Forms!frmUserRecipes!OLDRNUM

If it’s a text data type:

"FoodCode=""" & Forms!frmUserRecipes!OLDRNUM & """"

Provided the FilterOn property is False when you open the form via the
switchboard, which it should be by default, you should have no problem as
there is now no need for the form to evaluate the parameter
Forms!frmUserRecipes!OLDRNUM.

Ken Sheridan
Stafford, England
 

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