close form

kingsgambit

Registered User.
Local time
Today, 18:13
Joined
May 27, 2001
Messages
134
On my form I have a button which opens a calendar, when the user clicks on a date it puts the date into a text box and close.
If the user clciks on the button by accident,I want the user to be able to click anywhere on the form instead and the form will close. I tried OnLostFocus, but it puts the claendar behind the form. Any ideas?
 
Use the Click() event of the form's Detail.

Code:
Private Sub Detail_Click()
    DoCmd.Close acForm, Me.Name
End Sub
 
Is me.name the name of the form?
If so I tried the code and it still put the calendar form behind the form that is open
 
Is the calendar covering the whole of the form?
 
And yes, Me.Name, is the name of the form.
 
lol, that's what i asked.

Anyway, as the control covers the form you can't use the detail's click event or the form's click event.

The obvious workaround would be to extend the base of the form a little and fill it with a command button with a caption saying something like Cancel.

Then, put the DoCmd.Close acForm, Me.Name line on the command button's click event.
 

Users who are viewing this thread

Back
Top Bottom