Problem with working with MDIFrom properties

FunBunny
09-07-2003, 01:03 AM
Why doesn't this work?:

Private Sub mnuClose_Click()

If ActiveForm.ActiveControl Is Empty Then
'Close the child form with focus
Unload ActiveForm
Else ' if there is something in the box
Call mnuSave_Click ' allow user to save changes
Unload ActiveForm
End If


End Sub

The below works fine with I simply want to 'close' the window.

Private Sub mnuClose_Click()

'Close the child form with focus
Unload ActiveForm

End Sub

I'm not getting it. I have attached the project in a zip if it is needed to discern whats going on.

TIA for any assistance.

FunBunny

xBox
09-07-2003, 01:37 AM
Try with this Code ....

While Me.ActiveForm.MDIChild = True
Unload Me.ActiveForm
Wend


Thanks & regards
xBox

FunBunny
09-07-2003, 01:52 AM
Thanks for the reply xBox. I'm not sure where I would jam this code to make it work. I can get the form to unload with simply "Unload ActiveForm", thats not a problem. My issue is I want the app to check to see if the richtextbox is not empty. If it has text in it I want it to call the (working) module that allows it to save the file to the hard drive. If the richtextbox is empty, I want it to simply unload the form.

It seems that in my If statement, it doesn't recognize recognize the below objects:

ActiveFrom.ActiveControl

or

frmMain.ActiveForm.ActiveControl - where frmMain is the MDIParent

or

frmMain.ActiveForm.RichTextBox1 - where RichTextBox1 is the name of the rich text box.

I can't use a hardcoded object because there maybe multiple child forms open. I need to only close the active, which is something I could do before adding the if statement.

The code below appears to simply unload the form which is cool, but doesn't resolve my issue. I'm sorry for not making my dilemna clear the first time. Any thoughts? TIA.


Try with this Code ....

While Me.ActiveForm.MDIChild = True
Unload Me.ActiveForm
Wend


Thanks & regards
xBox

xBox
09-07-2003, 02:13 AM
Hi...

This below example u will get to know how many richtextbox controls in a current form.. so I hope this will helps...


Private Sub ChkRichTextVal(frm As Form)
Dim intC As Integer
For intC = 0 To frm.Controls.Count - 1
If TypeOf frm.Controls(intC) Is RichTextBox Then
If frm.Controls(intC).Text = "" Then
MsgBox frm.Controls(intC).Name
End If
End If
Next intC
End Sub

Private Sub Command1_Click()
Call ChkRichTextVal(Me)
End Sub


Cheers
XBox

FunBunny
09-07-2003, 02:39 AM
Thanks for sticking with me xBox. Before I read your last post, I solved the issue.

I changed:

"If ActiveForm.ActiveControl is Empty Then"

to

"If ActiveForm.ActiveControl = "" Then"

Everything is working good now. Thanks again.

FunBunny

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum