Hello,
As I am building a pos and inventory software in vb 6.0 with Ms-Access as database, I am building the face of the software where I have one MDImain form with toolbar and menus and related some mdichild form holding different informations (I have attached the image). main2 What now I want is that when I click the button in the toolbar of the MDImain form, another form related with mdichild form will open and help me to done the related task. For example, when the Catagory mdichild form is open under MDIMain and I click the "New" button in the toolbar of the MDIMain, the form for enter new catagory will appear and give me the scope to add new catagory in the database. I tried the following code,

Dim frm As Form
For Each frm In Forms
If Not frm.Name = "MDIMain" Then
Select Case frm.activeform
Case "frmcatagoryae"
Load frmcatagory
End Select
End If
Next frm

but failed to complete my desired task. Any suggestion will be very helpfull.
Although the first row of the lisview is selected, I want to accomplish that for further to modify or delete record. My first concern is how can I manage to add record by clicking to the new button and by opening another form to add record.

Why don't you just unload the form showing and load frmCategory? I think I'm missing something here... :)

I will try that ofcourse. But whats missing ?? I think I just have to convert it this way to unload the form :

   Dim frm As Form
    For Each frm In Forms
    If Not frm.Name = "MDIMain" Then
    Select Case frm.activeform
    Case "frmcatagoryae"
    Load frmcatagory : unload frmcatagoryae
    End Select
    End If
    Next frm

right ??

Unload frmcatagoryae

frmCatagory.Show 1 ''or 2. 1 is modal, 2 is not modul, can load other forms as well.

ok, now i have the following code

Dim frm As Form
For Each frm In Forms
If Not frm.Name = "MDIMain" Then
Select Case frm.ActiveForm
Case "frmcatagoryae"
Unload frmcatagoryae
frmcatagory.Show 1
End Select
End If

but I have following error
object doesnt support property or method

in the following line :

Select Case frm.ActiveForm

need the solution, plz.

Eliminate the entire sub. Add the code under the menu button that you created. When a user clicks on asay the category menu button, unload the form showing and load the categories form...

Unload frmcatagoryae
frmcatagory.Show 1

From my understanding of MDI Forms, here's something you can try.

In your mdi child forms add menu items that are specific to that form, with the same name that you have in the MDI Parent. For instance you said that when the Category form is open you want the New command to open a form related to it. So in the Category form put in a menu for New command and set the code in the click event to open the form you want. Now whenever you load it, its menu items will replace the ones in the mdi form.

As for toolbars, the simplest solution would probably be to give each child it's own toolbar

Thanks for the post. Andre as per your saying :

Eliminate the entire sub. Add the code under the menu button that you created. When a user clicks on asay the category menu button, unload the form showing and load the categories form...

Unload frmcatagoryae
frmcatagory.Show 1

if then I load frmcompanyae and want to add new company and load frmcompany, then ?? I have to write command for all the mdichild and related new form to open ??? is it ?

As per your advice tinstaffi, I have to make menu in all the mdichild, right ? Isn't it too time consuming ??

You only have to create the unique items not the whole menu.

How ? Can you plz show me a small demo ?

For instance you want the Menu Item New to do something different in your child form. With the design window for that form on top, in the tools menu you'll see the menu editor. Use that to make a menu item called new under the main heading of file. When you click on the menu item after your done, the code window will show, with the sub routine stub for the click event of that menu item. Put the code to show your new form in there. Now when you show this child form in the parent form, the menu item in the parent called new will be replaced with the child form's menu item called new. The main caveat to this is, it only applies to the menu not the toolbar. To have similar functionality in the toolbar, copy the toolbar from the parent form to each child. You don't have to copy all the code too. You can access it from the child form by making it public and using the form name(eg. MDIForm1.mnuFileNew_Click).

Thanks. I will try as much as per my understanding.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.