Filter removed after re-opening a form

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

Guest

Hi,
I have a form showing fields of Departments and its Employees. A combo box is used to filter all records of the Department I select. Then I click a command button, it opens up form2 showing that specific Employee's details (and closes form1). This works fine.

But when I close form2 by clicking a close command button I designed, form1 is reopened, but the filter is now removed. (i.e. form1 is reopened with 1st record showing)

Can I have form1 reopend with filtered records showing as before form2 is opened?
(Becasue form2 is just an additonal info to the user only) Perhaps some code in the AfterUpdate property of close command button in form2?

Many thanks for any help!

Regards,
Sam
 
Correction to my question:

Perhaps some code in *OnClick* property of the close command button in form 2?
 
Instead of closing Form1, how about hiding it? Its code will be:
DoCmd.Open "Form2", ...
Me.Visible = False

Then you can just show it again when Form2 closes:
Forms!Form1.Visible = True

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Sam Kuo said:
Correction to my question:

Perhaps some code in *OnClick* property of the close command button in
form 2?
 
Thanks, Allen. Your tips have always been very helpful to me.
But I apologize for not making my question clear. I've used a macro instead of [event procedure] in OnClick property. The macro consists of 2 actions, namely Echo and OpenForm (or CloseForm in form2).

Is it possible to add the hide action to my existing macro? I noted that there is an action called RunCode, but I have no idea how to do this after reading through HELP. Or would it be easier to just use your code below (because the macro in form1 tells Access what record to display in form2, and I don't know how to do this with VB)

Thanks alot,
Sam
 
In your macro, use the:
SetValue
action to set the value of:
Forms!Form1.Visible
to
False

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Sam Kuo said:
Thanks, Allen. Your tips have always been very helpful to me.
But I apologize for not making my question clear. I've used a macro
instead of [event procedure] in OnClick property. The macro consists of 2
actions, namely Echo and OpenForm (or CloseForm in form2).
Is it possible to add the hide action to my existing macro? I noted that
there is an action called RunCode, but I have no idea how to do this after
reading through HELP. Or would it be easier to just use your code below
(because the macro in form1 tells Access what record to display in form2,
and I don't know how to do this with VB)
 
You are a star, Allen! It does work perfectly.
Is it also possible to hide the Database Window?

Regards,
Sam

Allen Browne said:
In your macro, use the:
SetValue
action to set the value of:
Forms!Form1.Visible
to
False

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Sam Kuo said:
Thanks, Allen. Your tips have always been very helpful to me.
But I apologize for not making my question clear. I've used a macro
instead of [event procedure] in OnClick property. The macro consists of 2
actions, namely Echo and OpenForm (or CloseForm in form2).
Is it possible to add the hide action to my existing macro? I noted that
there is an action called RunCode, but I have no idea how to do this after
reading through HELP. Or would it be easier to just use your code below
(because the macro in form1 tells Access what record to display in form2,
and I don't know how to do this with VB)
Thanks alot,
Sam
 
Hi,
I have a form showing fields of Departments and its Employees. A combo box is used to filter all records of the Department I select. Then I click a command button, it opens up form2 showing that specific Employee's details (and closes form1). This works fine.

But when I close form2 by clicking a close command button I designed, form1 is reopened, but the filter is now removed. (i.e. form1 is reopened with 1st record showing)

Can I have form1 reopend with filtered records showing as before form2 is opened?
(Becasue form2 is just an additonal info to the user only) Perhaps some code in the AfterUpdate property of close command button in form2?

Many thanks for any help!

Regards,
Sam

Don't actually close form1 just set it not visible when opening form2,
then on form2s close event set it back to visible.

- Jim
 
Thanks! I did exactly that, and it works.

Jim Allensworth said:
Don't actually close form1 just set it not visible when opening form2,
then on form2s close event set it back to visible.

- Jim
 
Back
Top