Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Interface and Graphics > Open/Close vs Hide/Unhide Forms


Reply
 
Thread Tools Display Modes
  #1  
Old 01-14-2002, 07:57 AM
JenniferD
Guest
 
Posts: n/a
Question Open/Close vs Hide/Unhide Forms


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
Reply With Quote
  #2  
Old 01-14-2002, 09:31 AM
JenniferD
Guest
 
Posts: n/a
Post Got it....am I correct?

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
Reply With Quote
  #3  
Old 01-14-2002, 09:33 AM
Squirm's Avatar
Squirm Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

Forms have Hide and Show methods which will make them disappear and reappear:

Code:
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
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #4  
Old 01-14-2002, 09:37 AM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default

Squirm, I believe Jennifer is doing this in Access VBA, I don't think
it works the same way.
__________________
Posting Guidelines
Reply With Quote
  #5  
Old 01-14-2002, 09:39 AM
reboot's Avatar
reboot reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
Default re: Squirm

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.
Reply With Quote
  #6  
Old 01-14-2002, 12:10 PM
IanPatton IanPatton is offline
Junior Contributor
 
Join Date: Jul 2001
Location: UK
Posts: 216
Default

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
Reply With Quote
  #7  
Old 01-14-2002, 05:07 PM
JenniferD
Guest
 
Posts: n/a
Exclamation Thanks

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!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->