473,396 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Hiding/Unhiding form from menu bar and by clicking a button

Hi,

I'm new to this forum.
I'm developing an Access 2003 database. In that database I have a form that starts up when the database is opened. On this startup form I have buttons to open other forms. Those other forms I also can open from a custom menu bar. This to make the database as user friendly as it is possible.
Now I want to hide the startup form whenever I open another form by either opening it from the menu bar or either by clicking on a button on the startup form.
When the other form is unloaded, the startup form needs to be unhided.
Now, I do know the code to hide/unhide the startup form by clicking on a button on that form. But not in combination when a form is opened from the menu bar.
Is this workable? And if yes, how should I do in VBA code?

Thank you very much for your help.
Sep 15 '11 #1

✓ answered by Mihail

My practice:

From Form_Start I wish to open Form_Localitati by clicking a button named cmdOpen_Localitati:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdOpen_Localitati_Click()
  2.     Me.Visible = False
  3.     DoCmd.OpenForm "Localitati", , , , , , Me.Name
  4. End Sub
Note please that I pass the name of current form in OpenArgs arguments (, , , , , , Me.Name)

The code in Form_Localitati (the second form) will be:
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Dim FormaApelanta 'Retain the main form's name
  3.  
  4. Private Sub Form_Load()
  5.     FormaApelanta = Me.OpenArgs
  6.     ............
  7. End Sub
  8.  
  9. Private Sub Form_Close()
  10. Dim frm As Form
  11.     For Each frm In Application.Forms
  12.         If frm.Name = FormaApelanta Then
  13.             frm.Visible = True 'Make visible the main form
  14.     Exit For
  15.         End If
  16.     Next frm
  17.     ............
  18. End Sub

5 1770
pod
298 100+
although it might not be what is best for you, but you could put in the code to "hide all other forms" in each form's OnLoad event ... this way it does not matter how the form is opened
Sep 15 '11 #2
Mihail
759 512MB
My practice:

From Form_Start I wish to open Form_Localitati by clicking a button named cmdOpen_Localitati:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdOpen_Localitati_Click()
  2.     Me.Visible = False
  3.     DoCmd.OpenForm "Localitati", , , , , , Me.Name
  4. End Sub
Note please that I pass the name of current form in OpenArgs arguments (, , , , , , Me.Name)

The code in Form_Localitati (the second form) will be:
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Dim FormaApelanta 'Retain the main form's name
  3.  
  4. Private Sub Form_Load()
  5.     FormaApelanta = Me.OpenArgs
  6.     ............
  7. End Sub
  8.  
  9. Private Sub Form_Close()
  10. Dim frm As Form
  11.     For Each frm In Application.Forms
  12.         If frm.Name = FormaApelanta Then
  13.             frm.Visible = True 'Make visible the main form
  14.     Exit For
  15.         End If
  16.     Next frm
  17.     ............
  18. End Sub
Sep 16 '11 #3
NeoPa
32,556 Expert Mod 16PB
I'm afraid I had to reset the Best Answer as it doesn't actually answer the question. There is nothing in there to handle making the calling form visible again on close of the called form.

Personally, I handle this situation with a class that captures closing of a form and remembers where the open was called from, but the simpler answer has been posted already by Mihail. As it's already there I won't repeat it. I may suggest that such a call (using OpenArgs) is much more clear when using named parameters, but otherwise this is an easy and well laid out solution which really ought to have been selected as Best Answer.

I'm open to posting my class-based solution if anyone's interested, but it's less straightforward than using OpenArgs frankly.
Sep 26 '11 #4
Mihail
759 512MB
Hi !
Yes NeoPa. I am interested to see your solution because I wish to learn about classes. I know what the classes can do but I don't know HOW. So, if you are so kind... Thank you !
Sep 26 '11 #5
NeoPa
32,556 Expert Mod 16PB
Check out Class Module to Handle Opening Forms Hierarchically. Feel free to ask any questions on it, but not in the Insight unless it's relevant there.
Sep 26 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Ice Man | last post by:
Hi all How Can I submit a form by clicking on an image instead of the submit button? Thanks
1
by: Lance | last post by:
Is there a "best" technique for hiding a form's Close ControlBox button (i.e., the button with an "X" in the top-right corner of a form) but still show the minimize and maximize buttons? I've found...
1
by: MuZZy | last post by:
Hi, I'm trying to find a way to find out a form menu height/color as i think it changes depending on various Windows settings. I need to create a form of height/color of form menu so that i can...
0
by: ILCSP | last post by:
Hello, I am trying to create a form in Visual Basic.Net with a dynamically created Menu bar. I need the drop down part of a menu item (Reports) to be dynamically generated according to the...
11
by: Alex | last post by:
Hello all, I have a main form(say "form1") .i want to display another form(say "form2") on occuring of an event (say a button click) and want to hide it after some time so that it will again...
7
abouddan
by: abouddan | last post by:
Hi all My request has two faces: 1- I need to create my own menu in my project that runs when the application is start. But I want that menu to starts manuly, I mean by runnig codes so I can...
1
by: Kirthikaiitm | last post by:
Hi, I have a image button (APPLY) On clicking apply button how to move the content from textbox to another textarea. I wrote the code in JScript. But once i click APPLY button the form is...
7
by: ismailc | last post by:
Good day; When I click anywhere on the form a particular button remains selected & focused. Even while i'm busy typing in another textbox the button looks as if it's being selected with a dark...
11
by: samsanjay | last post by:
Hi everyone, i m a beginner in c#. i m trying to develop a notepad editor application in c# using windows forms.. i have created a find modeless dialog. when i click the find button, it is able to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.