Beginner programmer needs help! (Main menu creation) 
Author Message
 Beginner programmer needs help! (Main menu creation)

Hi, I am trying to build my first VB app. I have built my DB from Access and
I have created forms to link to certain tables in the DB. However, I wish to
create a Main Menu where I can choose which form to open. For instance, I
have Supplier Information Form, Customer Form, etc.

I wish to have a main menu where the user can choose to search a specific
form; supplier info or customer info. For example, the user wishes only to
see customer info and access it by clicking on a control button "Customer
Information".

My question is what is the easiest way to build a menu like that? I am
unfamiliar with how to link a main menu to certain forms.

Any help would be greatly appreciated or if you have any links where I can
check out it would be great.

Thanks,
Eddie
First Time VB programmer

--
______________________
Edward Hung

ICQ UIN: 3477872



Sat, 01 Dec 2001 03:00:00 GMT  
 Beginner programmer needs help! (Main menu creation)
There are several ways of doing this, but the basic idea is to load the
desired form when the user clicks on something, and perhaps hiding the
active form. Suppose you have a button to click on, then you should use

    Private Sub button_Click()

    Me.Hide
    Load desired_form [vbModal]

    End Sub

On exiting the desired_form, you can then

    Private Sub Form_Unload

    desired_form.Show

    End Sub

Hope this helps ....

Edward Hung heeft geschreven in bericht ...

Quote:
>Hi, I am trying to build my first VB app. I have built my DB from Access
and
>I have created forms to link to certain tables in the DB. However, I wish
to
>create a Main Menu where I can choose which form to open. For instance, I
>have Supplier Information Form, Customer Form, etc.

>I wish to have a main menu where the user can choose to search a specific
>form; supplier info or customer info. For example, the user wishes only to
>see customer info and access it by clicking on a control button "Customer
>Information".

>My question is what is the easiest way to build a menu like that? I am
>unfamiliar with how to link a main menu to certain forms.

>Any help would be greatly appreciated or if you have any links where I can
>check out it would be great.

>Thanks,
>Eddie
>First Time VB programmer

>--
>______________________
>Edward Hung

>ICQ UIN: 3477872



Sat, 01 Dec 2001 03:00:00 GMT  
 Beginner programmer needs help! (Main menu creation)

Hi,

try this in your MenuForm:

Sub Command1_Click()
    Load MyForm
    MyForm.Show vbModeLess,Me
End Sub

You load a form and set your "MenuForm" (Me) as the owner of the loaded form
(MyForm).
Setting the owner will close the Form when you close the Parent, a nice
feature...

Thorsten



Quote:
> Hi, I am trying to build my first VB app. I have built my DB from Access
and
> I have created forms to link to certain tables in the DB. However, I wish
to
> create a Main Menu where I can choose which form to open. For instance, I
> have Supplier Information Form, Customer Form, etc.

> I wish to have a main menu where the user can choose to search a specific
> form; supplier info or customer info. For example, the user wishes only to
> see customer info and access it by clicking on a control button "Customer
> Information".

> My question is what is the easiest way to build a menu like that? I am
> unfamiliar with how to link a main menu to certain forms.

> Any help would be greatly appreciated or if you have any links where I can
> check out it would be great.

> Thanks,
> Eddie
> First Time VB programmer

> --
> ______________________
> Edward Hung

> ICQ UIN: 3477872



Sat, 01 Dec 2001 03:00:00 GMT  
 Beginner programmer needs help! (Main menu creation)
You say you are a beginner so I'll throw out another idea.
BTW, I am a VB beginner but I have about 18 years in PC database design.

I think the look you want is with one big window (Parent Form) with drop
down menus.  Then, when the user picks a menu item, a form (Child Form)
comes up WITHIN the Parent Form.  This would be the customer form or the
inventory form, etc.

BTW - I only know VB 6.0

This is known as a MDI form (multiple document interface).  Here's how
to do it.  Start a new project (standard.exe).  Under Project Menu,
choose add MDI Form.  There are two tricks to remember:

One, under Project Menu go to Project Properties.  Change the Startup
Object from Form1 to MDIForm1.  The MDIForm1 is the "container" or
Parent and thus should be the Startup Object.  Form1 is the child in
this example.

The second trick is to go to the Properties Window for Form1 and change
the MDIchild property to True.  (Otherwise the Form1 is allowed to
"float" anywhere instead of being restricted to the size of the
MDIForm1.

Give MDIForm1 a big footprint and form1 a small footprint so you can see
how it works.

Finally, add a menu to MDIform1 by selecting the form and choosing the
menu tool from the tool bar across the top (third from left).  Add the
menu item "Test" to the Caption and "mnuTest" to the Name.  Click on OK
button.  Now when you click on the menu that was created in MDIform1, it
will bring up the mnuTest_Click() event.  Use the code shown below (a
slight variation from the other message).

Private Sub mnuTest_Click()
    Load Form1
    Form1.Show vbModeless
End Sub

Run the app.  If you need help with making a more advanced menu see a
book.  These menus will look much better and more professional than the
"button approach".  Good Luck

This is my first time ever helping someone that I don't know in 18 years
(because I always felt I would say something stupid), but in this case I
was sure I knew what you are looking for and I thought I could help.
Let me know if it helps!

Mark Hopkins
Computer Scientist

Quote:

> Hi,

> try this in your MenuForm:

> Sub Command1_Click()
>     Load MyForm
>     MyForm.Show vbModeLess,Me
> End Sub

> You load a form and set your "MenuForm" (Me) as the owner of the loaded form
> (MyForm).
> Setting the owner will close the Form when you close the Parent, a nice
> feature...

> Thorsten



> > Hi, I am trying to build my first VB app. I have built my DB from Access
> and
> > I have created forms to link to certain tables in the DB. However, I wish
> to
> > create a Main Menu where I can choose which form to open. For instance, I
> > have Supplier Information Form, Customer Form, etc.

> > I wish to have a main menu where the user can choose to search a specific
> > form; supplier info or customer info. For example, the user wishes only to
> > see customer info and access it by clicking on a control button "Customer
> > Information".

> > My question is what is the easiest way to build a menu like that? I am
> > unfamiliar with how to link a main menu to certain forms.

> > Any help would be greatly appreciated or if you have any links where I can
> > check out it would be great.

> > Thanks,
> > Eddie
> > First Time VB programmer

> > --
> > ______________________
> > Edward Hung

> > ICQ UIN: 3477872



Sat, 01 Dec 2001 03:00:00 GMT  
 Beginner programmer needs help! (Main menu creation)
The way I like to do it is to make control arrays of all my buttons on all my
forms and use a routine in my BAS module that controls all the forms loading and
unloading. Here's a quick example,

Code from a form,

Private Sub cmdControls_Click(Index As Integer)

    Select Case Index

        Case 0 ' load Main Form

                NextForm enumMain

        Case 1 ' load suppliers form and close the current form

                NextForm enumSuppliers, Me

    End Select

End sub

Then in the BAS modules I have this,

Public Sub NextForm(ByVal intCommand As Integer, Optional ByRef strForm As Form)

    If Not strForm Is Nothing Then Unload strForm  ' if you supplied a form

                                                   ' in the call, unload it.

    Select Case intCommand

        Case enumMain

            frmMain.Show

        Case enumSuppliers

            frmSuppliers.Show

    End Select

End Sub

I create a set of enum constants in the BAS module called FormNames and I put
all the names of all the forms I use there. Then I put the same style
cmdControls_Click code on all my forms. Now I use the same code to show my forms
from where ever I am in the program. You can even use this with the pulldown
menus that was suggested earlier. The reason I like this may or may not be
obvious. This has central control over the way any form is shown. If I always
want a form loaded Modal then I put that in the NextForm routine. If I need to
run a query against the database before a form can be used then I put that in
the NextForm routine as well. This works very well for me but as you've probably
already learned there's a b'zillion ways to to almost anything when programming.

Good Luck!
--
Ed Reed(CNE)
Nearfield Systems, Inc.



Mon, 03 Dec 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Beginner programmer needs help! (Main menu creation)

2. Access 2000: add menu to main menu bar

3. Add Menu Item to Main Word Menu

4. Pop-up Menu without having a Main Menu?

5. Creating menu item on the right most portion of main menu

6. Popup Menu hides Main MDI Menu

7. Help with dynamic popup menu creation

8. Need Help: Trouble adding a custom menu pick to a custom popup menu in VBA

9. Help needed: Sub Main

10. Need help with Sub Main

11. Need Help with PDF Batch Creation

12. Rookie needs HELP with Wizard creation!!!

 

 
Powered by phpBB® Forum Software