Retaining filter when switching forms

  • Thread starter Thread starter Chuck
  • Start date Start date
C

Chuck

I have a button on FormA that closes FormA and open FormB.
If the user has a filter applied to FormA I would like to
apply it to FormB when it is opened. Is this possible? How?

Thanks
 
Hmm...Not totally sure this will work, but it's worth a
whirl (I've used similar for getting data from controls in
other forms).

What you do is with the button that closes FormA, instead
of closing it, do Form.Visible = False. Then, for code
when FormB is open you do the following:

If SysCmd(acSysCmdGetObjectState, acForm, "FormA") =
OBJ_STATE_CLOSED Then
Exit Sub
End If
Else
Dim frm As Form
Set frm = Application.Forms("FormA")
'Then - here- you should be able to say something like
Me.Filter = frm.Filter

DoCmd.Close acForm, "FormA", acSaveYes
End if

In essence, by having formA invisible, you can still get
the data - and then, since you don't need it after the
filter is retrieved by formB, you can then close it.

Also, you'll have to substituate FormA in the commands
above with whatever the real name of the form is.

I hope this makes sense ^_^;; If you have any trouble,
let me know!

Sullivan
 
Back
Top