Solved

Calendar Control popping up on Delete

Posted on 2011-02-19
16
301 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
 

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 - Access MVP) earned 350 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 150 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
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now