Calendar Control popping up on Delete

I have a subform with a calendar control.  When I delete a record in the subform the calendar control pops up.  Why would this be happening?  I checked the tab index and it's 9.

ee-calendar.jpg
gcgcitAsked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Connect With a Mentor Database ArchitectCommented:
See image for the problem ... you are calling the Calendar code in the After Del Confirm.

Also ... not related, but you have a compile error - see 2nd image.  You need to fix that or calendar will not work.

mx
Capture1.gif
Capture2.gif
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Can you show all the code associated with the Delete or upload the db?
0
 
gcgcitAuthor Commented:
Private Sub cmdDelete_Click()
Dim RemovalWarning As Integer

On Error GoTo Err_cmdDelete_Click
   
RemovalWarning = MsgBox("Are you sure you want to remove this person?", vbYesNo, "Warning!")
   
If RemovalWarning = 7 Then
    Exit Sub
Else
    DoCmd.SetWarnings False
    DoCmd.RunCommand acCmdDeleteRecord
    DoCmd.SetWarnings True
End If

Exit_cmdDelete_Click:
    Exit Sub

Err_cmdDelete_Click:
        MsgBox Err.Number & " - " & Err.Description

    Resume Exit_cmdDelete_Click

End Sub
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
Jeffrey CoachmanMIS LiasonCommented:
Well there is certainly nothing in the code you posted that would open the calendar.

1. Let's verify the design:
"I have a subform..."
Then we can assume that this is a true subform that is physically *inside* (embedded in) a main form?
(Not a pop-up subform)

"I have a subform with a calendar control. "
Again, please be specific.  What do you mean by "subform with a calendar control"?
Is it embedded in the subform, or is it a pop-up calendar form?

2. What is the normal sequence of events that should call up the calendar normally?

3. "Why would this be happening?"
You mean this never happened before, and now it suddenly started happening?
(Or are you saying that this always happened.)
...in other words, did this system ever work normally?

4. Will you be posting a sample DB that demonstrates this phenomenon as requested by the first Expert?

JeffCoachman
0
 
gcgcitAuthor Commented:
Sorry for delay, too a little while to strip down this application to be a small sample.

See attached file, if you remove a person calendar control pops up.
ee-Calendar.mdb
0
 
Jeffrey CoachmanConnect With a Mentor MIS LiasonCommented:
You have a lot of confusing design elements here:

1. Your declarations are "lose" try tightening them up like so:
Dim strForm As String
Dim strSubForm As String
Dim strCtrl As String
Dim wd As Date

2. You have an undeclared variable "AGDForm" in your code as well.
(Your code would not compile because of this...)
This really needs to be declared.

3. You have your function calls on events directly.
Although this works, it is not commonly done. (For controlsources, Yes, ...but not commonly for Events)
To make your app easier to follow, you should put the function call in code.
Again, confusing is that the BeforeUpdate event is actually done in this way, but OnClick and OnEnter are not...

3. Which brings me to the reason for the issue.
The Date textbox is the next control in the tab Order immediately after the Delete button.
Hence the focus will always move to the Date textbox automatically.
And since your code to "Popup" the calendar is on both the OnEnter and OnClick events of the date textbox, it will always fire. (opening the calendar)
You also have this function call on the AfterDelete confirm event of the subform, again, forcing the calendar to open.
(again, this was difficult to find because the function call was not done in Code.)

4. Although "popping up" the calendar automatically seems like a good idea, it is not commonly done.
Most of the time, a seasoned data entry person can type a specific date in much faster than they can "Navigate" to it on a calendar control.
(just type 6/17/1994 into the control directly, then try "navigating" to it from the control, then see which is faster...)
;-)
So the calendar control is typically invoked on command (via a button click) only when needed.

Revised db file attached.

JeffCoachman
ee-Calendar.mdb
0
 
Jeffrey CoachmanMIS LiasonCommented:
sorry MX.

Left this Q open while I did house work...
(Oy!)

Jeff
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
<Housework ... so THAT'S you are not coming to the summit!>

mx
0
 
gcgcitAuthor Commented:
I stripped down a database and removed loads of fields, that's why some of the code seems un-used... I just didn't remove it all... but the full system does compile... thanks for the feedback on that though.

Having the pop-up in the After-delete Confirm was the issue - thanks for spotting that... I don't know how that code got in that event - it's not supposed to be there!!!

Who should I give the points to?   DatabaseMX posted first but Boag2000 gave long description also a solution but had forgot to post?  Please advise what both of you will be happy with and I'll close ticket and assign points.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
You have to decide on the points ... based on the post that solved the problem.

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Just noting the problem was clearly the After Del Confirm event ...

mx
0
 
gcgcitAuthor Commented:
More points allocated to Database MX because the screenshot made it very easy to find the issue AND he answered first.  

Boag200 did answer but unfortunately it was posted later but helpful information was provided so I gave him partial points.  

Hope you both consider this fair.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
cool.

mx
0
 
Jeffrey CoachmanMIS LiasonCommented:
I would have had no issue with MX getting the points.
It's first come first serve...

Besides, my post will still be visible in the thread.

Now, ...if the points had a monetary component....
;-)

Jeff
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Yeah ... IF $$$$$$ lol.
np on split ...
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
gcgcit:
You made an intelligent call on the points.
thx.mx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.