|
-
Jun 30th, 2004, 12:54 PM
#1
Thread Starter
Lively Member
MDI problem ! HELPPPPP
i have a problem with the MDI
i have the main menu and i have set the main menu event with MainMenu_Activated
inside that i have a if statement called
If newclientinfo.CheckSaving1 = 1 Then
MenuItem14.Enabled = True
Else
MenuItem14.Enabled = False
End If
End sub
and in the child form call newclientinfo when the newclientinfo _closed i have a SQL command
select the client if the datareader read than i set the CheckSaving1 to 1
why it wont work ??? the CheckSaving1 is set to Public
-
Jun 30th, 2004, 01:02 PM
#2
Frenzied Member
What is newclientinfo?
For a quick answer, I'd suggest avoiding MDI forms. They're a pain.
-
Jun 30th, 2004, 01:05 PM
#3
Thread Starter
Lively Member
the newclientinfo is a form and is a child of the main menu
i wanna use a MDI format to develop a system
so please help
-
Jun 30th, 2004, 02:48 PM
#4
Fanatic Member
MDI forms rule
I dont really understand what your trying to do but
i guess your problem is the fact your calling your perant mdi from your child form and it errors this is most likely becuase child forms speaking to perants ant all that
If you add a module to your solution then add a public variable of
pulbic FrmPerant as "what ever the perant is called"
then from the child form to access properties of the perant just use
frmPerant.WHATEVER
modules are global to the entire solution they do not need instanciating there they can be called when ever how ever......
hope it helps
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
-
Jul 1st, 2004, 05:39 AM
#5
Hyperactive Member
Carl, you are correct, MDI forms do rule, now to try and help ninjaX.
How are you instantiating your form?
And is the name of the actual form newclientinfo or is that the instance name?
The problem with trying to reference controls on a form is that if you come from VB6 or earlier, then by just referencing a form by it's actual name worked fine, that is not true in VB7.
-
Jul 1st, 2004, 10:09 AM
#6
Thread Starter
Lively Member
i got one simple MDI question
i can use what event to keep track what the child has done, example my parent window will continue keep track when the form is activate i have try the activated event before but no use.
example
i have a child form call newclient and parent is mainmenu
after the newclient click at the save button, some of the main menu function will set the enabled to true can i know how to do that ????
coz some of my function cannot be use if the user dont click at the newclient save button
-
Jul 1st, 2004, 10:19 AM
#7
Hyperactive Member
Create a public method in your MDI parent form and have the child form call that method as the last call in the save button click event.
VB Code:
Private myParent As New mainmenu
Private Sub btnSave_Click()
'Other code goes here
myParent.EnableControls
End Sub
-
Jul 1st, 2004, 10:39 AM
#8
Thread Starter
Lively Member
is it create at the parent form or inside the child form ???
why the myParent.EnabledControls cannot use one ?
-
Jul 1st, 2004, 11:09 AM
#9
Hyperactive Member
Well then
In your child form, declare a public event like "Saved" and raise the event to all listeners (should only be your MDI container)
VB Code:
Public Event Saved
Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save.Click
'Other code goes here...
RaiseEvent Saved
End Sub
And in your MDI container form declare your child form withevents and code the event handler
VB Code:
Private WithEvents ChildNew As frmChild
Private Sub ChildNew_Complete() Handles ChildNew.Complete
MessageBox.Show("It worked")
End Sub
This should do the trick nicely . . . it works on my machine
-
Jul 1st, 2004, 11:21 AM
#10
Thread Starter
Lively Member
Sorry CyberHawke
Private WithEvents ChildNew As frmChild
Private Sub ChildNew_Complete() Handles ChildNew.Complete
MessageBox.Show("It worked")
End Sub
.Complete Wont Work
-
Jul 1st, 2004, 11:24 AM
#11
Hyperactive Member
Sorry, my bad, that's what I get for editing my code in this window.
VB Code:
Public Event Saved
Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save.Click
'Other code goes here...
RaiseEvent Saved
End Sub
VB Code:
Private WithEvents ChildNew As frmChild
Private Sub ChildNew_Saved() Handles ChildNew.Saved
MessageBox.Show("It worked")
End Sub
Whadayamean it doesn't work....
It works fine on my machine!

-
Jul 1st, 2004, 11:37 AM
#12
Thread Starter
Lively Member
Sorry CyberHawke
Donno why my coding cannot work with the code
ai ~~
Public Event Saved
Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save.Click
'Other code goes here...
RaiseEvent Saved
End Sub
this one i put it in my child called newclient
Private WithEvents ChildNew As frmChild
Private Sub ChildNew_Saved() Handles ChildNew.Saved
MessageBox.Show("It worked")
End Sub
this one i put in my parent form called main menu
but after i click the save button it wont work for me
is it my code for problem ??
-
Jul 1st, 2004, 11:42 AM
#13
Hyperactive Member
It looks correct, I guess you should paste the code out of your actual module here, because this works fine for me
Whadayamean it doesn't work....
It works fine on my machine!

-
Jul 1st, 2004, 11:45 AM
#14
Thread Starter
Lively Member
the parent for is call mainmenu the code is like below:
Dim newclientinfo As New newclientinfo
Private WithEvents ChildNew As newclientinfo
Private Sub MenuItem13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem13.Click
If Check = 0 Then
doccode.ShowDialog()
newclientinfo = New NewClientInfo
If doccode.CheckCancel <> 1 Then
newclientinfo.code_TextBox.Text = doccode.DocCode_TextBox.Text
TempDocCode = doccode.DocCode_TextBox.Text
newclientinfo.Show()
newclientinfo.MdiParent = Me
Check += 1
End If
If doccode.CheckCancel = 1 Then
doccode.CheckCancel = 0
TempDocCode = 0
End If
Else
Dim mainmenu As New MainMenu
mainmenu.Show()
End If
Private Sub ChildNew_Saved() Handles ChildNew.Saved
MessageBox.Show("It worked")
End Sub
===============================================
the code below is for my new client form
Public Event Saved()
Private Sub save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save.Click
Dim mainmenu As New MainMenu
Dim IntSave As Integer
Dim ClientName As String
IntSave = MsgBox("Do You Want To Save Your Data ?", MsgBoxStyle.OKCancel, "Save")
If IntSave = DialogResult.OK Then
Try
OleDbConnection1.Open()
'*********************************************
Dim DataReader As OleDb.OleDbDataReader
OleDbDataAdapter1.SelectCommand.CommandText = "SELECT Client From Client Where Client = '" & ClientName_TextBox.Text & "' And Code = '" & code_TextBox.Text & "' "
DataReader = OleDbDataAdapter1.SelectCommand.ExecuteReader
If DataReader.Read Then
MessageBox.Show("Client Name Already Been Save. Thank You", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error)
Else
DataReader.Close()
SaveClientInfo()
CheckSaving = 1
RaiseEvent Saved()
End If
Catch ex As Exception
MsgBox(ex.ToString())
Finally
OleDbConnection1.Close()
End Try
If IntSave = DialogResult.Cancel Then
MessageBox.Show("Data Not Save")
CheckSaving = 0
End If
End If
End Sub
is it enough ?
thanx for helping me
-
Jul 1st, 2004, 11:50 AM
#15
Hyperactive Member
two things, first, can you send me your code?
second, if you are going to paste code here, please use the vb format tags, it makes it much easier to read thanks
Whadayamean it doesn't work....
It works fine on my machine!

-
Jul 1st, 2004, 12:01 PM
#16
Hyperactive Member
Remove this line:
Dim newclientinfo As New newclientinfo
Change this line:
newclientinfo = New NewClientInfo
to:
ChildNew = New newclientinfo
Replace all other references to newclientinfo to ChildNew
From what I am reading here, that should fix it.
Whadayamean it doesn't work....
It works fine on my machine!

-
Jul 1st, 2004, 12:43 PM
#17
Thread Starter
Lively Member
-
Jul 1st, 2004, 01:36 PM
#18
Hyperactive Member
Ok, if I understand you correctly, you have two forms, your main form (mainmenu) and your client form newclientinfo, now when your user creates an instance of your newclientinfo form from the mainmenu form and then closes the mainmenu form, the newclientinfo form goes away also. Is that correct?
Whadayamean it doesn't work....
It works fine on my machine!

-
Jul 1st, 2004, 03:05 PM
#19
Thread Starter
Lively Member
sorry, actually i have create 2 main form
If Check = 0 Then
Do my things here
Else
Dim mainmenu As New MainMenu
mainmenu.Show()
End If
i use the check to detect is the user is click at the new client this menu item or not if not it will display the new client
if yes it will help me to create another parent and when i have 2 parent is open, i call it parent 1 and parent 2 if i close the parent 1 the parent 2 will also close it, it is possible to make the 2 parent independent like the microsoft word ???
and the second problem is that i have open a form and the form have a document code textbox call 123, and when user is try to open the form document code 123 and the system will help me to detect is the form document code is open or not ?????
thank you very much
sorry to disturbing you again
Last edited by ninjaX; Jul 1st, 2004 at 03:35 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|