Problems closing form (1 Viewer)

Malcy

Registered User.
Local time
Today, 07:05
Joined
Mar 25, 2003
Messages
586
I have two forms open, one of them is effectively the master form and the other a child form. It sort of acts like a sub form but is a form in its own right.
The master form has five buttons each of which opens a separate child form with (differnet) data linking directly to the record in the master form. Each of the child forms has been sized to fit into the same (cleared) space on the master form.
There is no problem when there is matching data for the child form. You simply hit the "close form" button and the child form closes leaving you back with the master form exactly as it was.
However, when there is no matching data for the child form you simply get a blank space on the screen without the "close form" button, and so are stumped.

I thought I had got the answer by putting the following code in the OnOpen event.

*****************
Private Sub Form_Open(Cancel As Integer)

If Me.RecordsetClone.RecordCount = 0 Then
DoCmd.Close
MsgBox "Sorry, there are no entries for this record", vbInformation, "No Records Found"

End If

End Sub
**********************

For some reason which I do not understand this does close the child form as expected but it has the unwanted effect of also resizing the master form.
I cannot for the life of me work out what is happening, does anyone else have an idea.
It is critical for the smooth running of the application that the master form is not resized but stays exactly as is.
Any help would be greatly appreciated.
Thanks in advance

Malcy
 

AncientOne

Senior Citizen
Local time
Today, 07:05
Joined
Mar 11, 2003
Messages
464
Have you tried using Cancel=True instead of DoCmd.Close?
 

Malcy

Registered User.
Local time
Today, 07:05
Joined
Mar 25, 2003
Messages
586
Magic!!!
Thank you enormously.
It still doesn't explain why the original form resized but that now becomes less relevant!!!

Best wishes

Malcy
 

Users who are viewing this thread

Top Bottom