Solved

Choosing a Day in the ActiveX Calendar

Posted on 2010-11-08
14
449 Views
Last Modified: 2012-06-21
When you choose a month and year on the active x calendar in access, is there a way, using VBA to default it to a day automatically ?
0
Comment
Question by:ml-sd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
14 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 34086172
if you are going to set the day, why don't you just set the date so you cover all 3 elements of a date.
eg

cal.Value = CDate("10/11/2011")

or use dateserial (yyyy,mm,dd)

cal.value = dateserial(2011,11,10)
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 34086575
yeah, I played around with this for a while and there was no easy way (at least that I could find) to do this via an Event...
0
 

Author Comment

by:ml-sd
ID: 34086712
The input from the the active X calendar opens up a monthly calendar form.....   therefore the actual day isn't important  and users forget the keystroke....  i was trying to just make the day any day without input.
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 65

Expert Comment

by:rockiroads
ID: 34086854
so why not default to todays date then?

cal.value = now()
0
 

Author Comment

by:ml-sd
ID: 34087768
I have the form load event todays date.  then the user can choose a different month to look at.
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 34087940
so any particular day, on the NewMonth event, set it to the 1st?

eg control called cal

Private Sub cal_NewMonth()
    cal.Value = DateSerial(Year(cal.Value), Month(cal.Value), 1)
End Sub

you also have a NewYear event
0
 

Author Comment

by:ml-sd
ID: 34088251
Im using some code simillar to this...  i put in the lost focus event .However, unless a day is pressed  it dosent work.  I then created a subroutine  using your code and received this error : Runtime error 424 object required
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 34088287
can you post what you have done so far? you did change "cal" to the name of your control right?
0
 

Author Comment

by:ml-sd
ID: 34120792
Im sorry for the delay in posting, I got tied up on another job...  Thanks so much for your patience.
Here is what I have...   i was going to use the lost focus event on the calendar on the datepickerF,  but i couldnt get it to work
Calendar.mdb
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 34121362
Your control is called Calendar

If the attached code is added to your form, then the first day of the month is selected each time you change the month or year
Private Sub Calendar_NewMonth()
     Calendar.Value = DateSerial(Year(Calendar.Value), Month(Calendar.Value), 1)
End Sub

Private Sub Calendar_NewYear()
     Calendar.Value = DateSerial(Year(Calendar.Value), Month(Calendar.Value), 1)
End Sub

Open in new window

0
 

Author Comment

by:ml-sd
ID: 34121766
Well, it almost works....   I does default a date.   But you cant change the month and year at the same time.  also when I go back to the form to choose another month  It will not allow me to make another choice ??
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 34122115
Ok, gave it some test as realised when selecting a new month it does not update the calendar value! Let me look into this a little more
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
ID: 34123186
I cannot seem to find anyway of tracking the change of a month or year apart from the new methods. I have checked the object properties using object browser and nothing sticks out. I wonder if perhaps the way forward on this is to set show date selectors off then add your own dropdowns. We can capture the afterupdate on this and set the date accordingly
0
 

Author Closing Comment

by:ml-sd
ID: 34168307
as it turns out, in access 2003, I have found no way to auto choose a date with the active x calendar. I am told in 2007 and 2010 you can. The suggestion using some combo boxes and create my own choices worked.  
thanks for all your input
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

736 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