Open/Close vs Hide/Unhide Forms

JenniferD
01-14-2002, 07:57 AM
I have an application which starts with a Main Screen. From there, you open a Form where the user selects a Job they want to edit. Once they select a Job, it then opens an Edit Form and from there, they can go to the 'Select For Print' Form which allows them to chose records to print before actually printing. The problem is that I am not controling the forms efficiently.

Currently, I close most of the forms once the user moves on, but then I have a BACK button on most forms which allows the user to step back one form. When they do so, I was re-opening the forms (DoCmd.OpenForm). I think this is eating memory when I am constantly opening and closing forms. I want to understand how to just hide them and reload them when the user presses BACK rather then open and close. Here is the hierarchy so you can better understand the flow:

Main Screen (cmd button to open Job Select)

Job Select (cmd button to open Edit Job, cmd to go back to main)

Edit Job (cmd button to open Select for Print and cmdbutton to go back to Job Select)

Select for Print (cmd button to open Report and cmd button to go back to Edit Job and one to return to Job Select)


The Edit Job and Select For Print forms are being sent a filter in the DoCmd WHERE clause to filter out only the job in question. I wasn't sure how to hide/unhide or actuivate/unactivate the forms and then refresh with the new filters each time.

I guess what I am asking is when the user goes to the Job Select Form from the Main Screen, I want to just hide the Main screen so they can easily go back to it later...then from the Job Select, be able to go to the Edit Job and hide the Job Select so it can be returned to.

The other tricky part for me is then going to the Select For Print screen... currently, i have the Select For Print just opening OVER the Edit Job screen so that when the user clicks the BACK button from the Select For Print, it just closes the Select For Print which puts them back onthe same record in the Edit Job. However, if they make a change and then click the 'Select For Job', I am REOPENING using the DoCmdOpenForm which I think will be slow and eat memory.

What I would ideally like to do (if it is the most efficient) is just open all of the forms needed, and then just pass the filter each time I call the form and hide the others. Which property do I use for this type of control? (activate, hide, load, etc)....Also, what is the proper syntax for changing Form properties from within a different form?

I am sorry this is confusing...if I left anything out (like the fact that I am using Access 2000 ), just let me know.

Thanks for any help.....and thanks to anyone who can understand what I am asking here :)

JenniferD
01-14-2002, 09:31 AM
Hi again.....as it turns out, i think i have figured it out. I am going to use the Forms!frmname.Visible property and toggle them that way. I wasn't sure how to do this, but I have it working. THanks for all those who read this anyway.

This is the best way to do this right? I ahve about 10 firms to load in the beginning, then I will just use the visible prop instead of opening and closing.

Thanks,

Jennifer

Squirm
01-14-2002, 09:33 AM
Forms have Hide and Show methods which will make them disappear and reappear:

Private Sub Form_Load()
Form1.Show 'Show Form1
Form2.Hide 'Hide Form2
'statements
'go
'here
Form1.Hide 'Hide Form1
Form2.Show 'Show Form2
End Sub

Thinker
01-14-2002, 09:37 AM
Squirm, I believe Jennifer is doing this in Access VBA, I don't think
it works the same way.

reboot
01-14-2002, 09:39 AM
I'm pretty sure she's talking Access and not Visual Basic. Access forms may or may not have .Show and .Hide

I'm not sure.

IanPatton
01-14-2002, 12:10 PM
This will open another form from a form in access and can be placed in a button click event or the form click event etc

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "UserForm2"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command1_Click:
Exit Sub

This hides a form without unloading I'm not quite sure how to make the form of your choice to appear if more than 2 forms are open

Private Sub Command0_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "UserForm2" 'or form of choice
Form.Visible = False

Exit_Command1_Click:
Exit Sub

End Sub

Hope this helps

Regards
Ian

JenniferD
01-14-2002, 05:07 PM
Thanks everyone, I did get the controls working much faster and what I hope to be more efficient. I ran into one snag with the filters i am using though.
I put another post called 'Another Filter Question' in the VBA/Office Thread describing my new problem.

if anyone can help me out, it would be great!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum