Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 06-19-2003, 11:30 AM   #1
Malcy
Newly Registered User
 
Join Date: Mar 2003
Location: Edinburgh, Scotland
Posts: 586
Thanks: 1
Thanked 0 Times in 0 Posts
Malcy
Problems closing form

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

Malcy is offline   Reply With Quote
Old 06-19-2003, 11:38 AM   #2
AncientOne
Senior Citizen
 
Join Date: Mar 2003
Posts: 464
Thanks: 0
Thanked 1 Time in 1 Post
AncientOne
Have you tried using Cancel=True instead of DoCmd.Close?
AncientOne is offline   Reply With Quote
Old 06-19-2003, 11:41 AM   #3
Malcy
Newly Registered User
 
Join Date: Mar 2003
Location: Edinburgh, Scotland
Posts: 586
Thanks: 1
Thanked 0 Times in 0 Posts
Malcy
Magic!!!
Thank you enormously.
It still doesn't explain why the original form resized but that now becomes less relevant!!!

Best wishes

Malcy

Malcy is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump




All times are GMT -8. The time now is 06:12 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World