Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Calendar Seminar Lessons    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Calendar DblClick Gives Type Mismatch Error
Kim Boren 
       
14 days ago
Hello, I just started working with the April 1 2025 calendar database. In the older version i would double click on a day and I would get a form to add information for that day. In the 2025 calendar i double click and get an error message: the expression On Dbl Click you entered as the event property setting produced the following error: Type Mismatch.
Would someone be able to tell me why I am getting this error?
Thanks,
Kim
Richard Rost  @Reply  
          
13 days ago
Yes, this is happening because if you double-click on a date that has no values, then it's passing a null to the OpenDay function, which is looking for a long. That works fine if you have a value there because it passes the long integer, which is the ID of that calendar item. If it's an empty date, that passes a null.

The way to fix it is to have the OpenDay function just accept a variant so it can take that null in. If it gets a null, then you can just open the form to add a new date. Otherwise, open the record that sends in. I'll fix the template, but here's the fix for now if you want to put it in your database.

Function OpenDay(D As Variant)

    If IsNull(D) Then
        DoCmd.OpenForm "CalendarF", , , , acFormAdd
    Else
        DoCmd.OpenForm "CalendarF", , , "CalendarID=" & D
    End If

End Function


This way, if it gets a null value, it'll open to a new record. Otherwise, it will open that calendar item. Another thing I'd like to add is that if you do double-click on a date that doesn't have any items in it, when it opens up to add, it should open up to add and default that date for you. Give me a few minutes. I'm gonna add that too. All of this is moot because I've got a calendar 2.0 database coming out soon lol.
Richard Rost  @Reply  
          
13 days ago
Okay, what I did was I added another event, which is the on got focus event. Whenever you click on a field, it'll set a temp var noting what the last box you clicked on was, so it knows what date you've selected, and then when you open up the form that adds the new item. The default value reads that temp var.

Add to the MonthlyCalendarF Form Load event where it creates the events:

Me.Controls("Day" & X).OnGotFocus = "=SetLastClickedDate(" & X & ")"

Add to Global Mod:

Public Function SetLastClickedDate(BoxClicked As Long)

    TempVars("LastClickedDate") = Forms!DatePickerF!MonthlyCalendarF.Form.Controls("Date" & BoxClicked).Value

End Function


Set the Default Value property of the DateTime field on the CalendarF to:

=TempVars("LastClickedDate")

And there you go! You got a bug fix and a little cool addition for today.
Richard Rost  @Reply  
          
13 days ago
I uploaded my database to the lessons page. Enjoy!
Add a Reply Upload an Image
Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 8/5/2026 8:35:55 AM. PLT: 0s