Having To Click Close Button Twice

startingover0001

New member
Local time
Today, 04:10
Joined
May 3, 2012
Messages
7
I posted this on another forum and got no responses, so I'm hoping for a little bit better here.

I've searched the forum for this but so far what I've found does not apply in my case.

I have a main form with a close button on it, and a subform in continuous form with no close button on it. The problem is that after adding or editing a record on the subform, even after setting focus to the close button on the main form, I have to click the button twice to close the form. The first click always puts the cursor and focus back on a field in the subform. I've changes setting where the focus goes, but clicking on any control back on the main form simply places focus on the subform field again. There is no code here that should do this, and putting a break on the close button does not even get activated until you click it a second time. There's nothing in Current for either form to cause redirection nor any other place, but it is going someplace and I can't figure out how to find out what it's doing. Using the immediate and watch windows produces nothing. Any ideas?

The code for the main form is:

Private Sub cmdAdd_Click()

[fSetGuests1Sub].Form.AllowAdditions = True
[fSetGuests1Sub].SetFocus
[fSetGuests1Sub].Form![Arrival].SetFocus
DoCmd.GoToRecord , , acNewRec

End Sub

Private Sub cmdEdit_Click()

[fSetGuests1Sub].Form.AllowEdits = True
[fSetGuests1Sub].SetFocus
[fSetGuests1Sub].Form![Arrival].SetFocus
DoCmd.GoToRecord , , acLast

End Sub
'------------------------------------------------------------
' cmdClose_Click
'
'------------------------------------------------------------
Private Sub cmdClose_Click()

DoCmd.Close , ""

End Sub

That's all the code there is on that form.

On my subform, the code is:

Private Sub Arrival_AfterUpdate()

Me.VisitingPeopleID = Forms![fSetGuests]![txtPeopleID_Tenant]
Me.Visiting = Forms![fSetGuests]![cboTenant].Column(4)

End Sub

Private Sub NumGuests_AfterUpdate()

If Me.Dirty Then Me.Dirty = False
'Me.AllowAdditions = False
'Me.AllowEdits = False
'Me.Requery
'Me.Refresh

Forms![fSetGuests1].SetFocus
Forms![fSetGuests1]![FName].SetFocus
Forms![fSetGuests1]![fSetGuests1Sub].Enabled = False

End Sub

Anything you see commented out is something different I've tried to eliminate the problem. No matter where you click on the main form, the detail, the close button or even another field, it always goes back to the subform's first field, usually in a new record.
 
Have you tried being explicit:

DoCmd.close acForm, Me.Name
 
Yes. It's not having a problem closing..it's having a problem closing the first click of the close button. The only thing I've been able to discern is that even upon putting the focus on the close button...it's not getting it. I can't figure out what is.
 
I've attached a sample just to demonstrate.

Open fSetGuests. Choose a name from each dropdown, then select the edit dates button. When that form opens up, click edit dates and add some random dates. After you include the number of guests, you will notice that the focus automatically returnes to the first field. Click close. It will not. Not until you hit it a second time.
 

Attachments

Place the close button in the "Form Footer" of the subform.
 
Well, that seems to work. Seems odd though. I've never had to do that before. While that does work, it's still going to be a curious issue in my head always wondering. Thx for your solution.
 
The problem is the Calender tools, if you manually type in the date there is no problem, also if you first set focus to another control, no problem.
 
I wondered if the calendar might not be part of the issue, but I hadn't heard of it before. As far as resetting the focus, if you're referring to after updating a field and then setting focus back to the main form, I have already done that and it does no good.
 

Users who are viewing this thread

Back
Top Bottom