Filter removed after re-opening a form

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
 
G

Guest

Correction to my question:

Perhaps some code in *OnClick* property of the close command button in form 2?
 
A

Allen Browne

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?
 
G

Guest

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
 
A

Allen Browne

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)
 
G

Guest

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
 
J

Jim Allensworth

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
 
G

Guest

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
 

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