Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Calendar Control popping up on Delete

Posted on 2011-02-19
16
Medium Priority
?
346 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:gcgcit
  • 8
  • 4
  • 4
16 Comments
 
LVL 75
ID: 34933891
Can you show all the code associated with the Delete or upload the db?
0
 

Author Comment

by:gcgcit
ID: 34942989
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
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 34955620
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:gcgcit
ID: 34973071
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
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 1400 total points
ID: 34973869
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
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 600 total points
ID: 34974209
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
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 34974221
sorry MX.

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

Jeff
0
 
LVL 75
ID: 34974264
<Housework ... so THAT'S you are not coming to the summit!>

mx
0
 

Author Comment

by:gcgcit
ID: 34980106
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
 
LVL 75
ID: 34981582
You have to decide on the points ... based on the post that solved the problem.

mx
0
 
LVL 75
ID: 34981597
Just noting the problem was clearly the After Del Confirm event ...

mx
0
 

Author Closing Comment

by:gcgcit
ID: 34982303
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
 
LVL 75
ID: 34982391
cool.

mx
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 34982674
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
 
LVL 75
ID: 34982706
Yeah ... IF $$$$$$ lol.
np on split ...
0
 
LVL 75
ID: 34982710
gcgcit:
You made an intelligent call on the points.
thx.mx
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question