473,320 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

MSCAL.Calendar.7 Default Date

JamesDC
66
Hey all,

How do I set the default date of my MSCAL.Calendar.7 calendar to today's date? I have it on one of my forms so that an employee can click on a given date and bring up the records form there. I just want the data to automatically be today's date, instead of having to click the desired date (which in almost all cases will be the current day's date).

Thanks in advance,

James
Feb 12 '07 #1
21 20433
Michael R
176 100+
Hey all,

How do I set the default date of my MSCAL.Calendar.7 calendar to today's date? I have it on one of my forms so that an employee can click on a given date and bring up the records form there. I just want the data to automatically be today's date, instead of having to click the desired date (which in almost all cases will be the current day's date).

Thanks in advance,

James
You can add this to form's on open event, Calendar1 being your MSCAL.Calendar.7 name property value:

Me.Calendar1.Value = Date
Feb 12 '07 #2
JamesDC
66
I have the form's on Open event set as Restore. How do I set multiple commands to this event? Such as the calendar update command?
Feb 12 '07 #3
Michael R
176 100+
I have the form's on Open event set as Restore. How do I set multiple commands to this event? Such as the calendar update command?
Right-click on the square in the upper left corner of the form and click 'propreties'. A box should open with the title "Form". Go to event tab, click on the On Open event, and there will be appear a "..." button on the left. Click on it, and add the code between those lines -
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
right here
Expand|Select|Wrap|Line Numbers
  1. End Sub
If "Restore" was written on that line from where you pressed "..." that was probably a macro, so you should add this line:
DoCmd.RunMacro "Restore" to the code I gave you.

Close the VB window and view your form.
Feb 12 '07 #4
ADezii
8,834 Expert 8TB
Hey all,

How do I set the default date of my MSCAL.Calendar.7 calendar to today's date? I have it on one of my forms so that an employee can click on a given date and bring up the records form there. I just want the data to automatically be today's date, instead of having to click the desired date (which in almost all cases will be the current day's date).

Thanks in advance,

James
As previously indicated, assuming your Calendar Name is Calendar1 then place this code in the Form's Load Event - not Open:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.   Me![Calendar1].Value = Date 
  3. End Sub
Feb 12 '07 #5
Michael R
176 100+
As previously indicated, assuming your Calendar Name is Calendar1 then place this code in the Form's Load Event - not Open:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.   Me![Calendar1].Value = Date 
  3. End Sub
Also, I forgot to mention, choose 'code builder' while pressing the "..." button from On Open event line in the propreties box.
Feb 12 '07 #6
JamesDC
66
THanks for the help so far,

I'm running into problems with the Date command. The person who created the database used Date as the name of a field in the database which makes the Date command in VB useless. Is there another way around this date issue? I've tried using Now(), but it causes an error that requires debugging, which I don't know how to fix :(

Also, is there a problem with having the calendar named Calendar? I'm not sure if that is also a command somewhere.
Feb 12 '07 #7
ADezii
8,834 Expert 8TB
THanks for the help so far,

I'm running into problems with the Date command. The person who created the database used Date as the name of a field in the database which makes the Date command in VB useless. Is there another way around this date issue? I've tried using Now(), but it causes an error that requires debugging, which I don't know how to fix :(

Also, is there a problem with having the calendar named Calendar? I'm not sure if that is also a command somewhere.
__1 You should have no problem using Format(Now(), "mm/dd/yyyy") instead of Date.
__2 What is the nature of the Error caused by using Now()?
__3 Calendar is part of the Class Name defining the OLE Object as in MSCAL.Calendar.7. Simply rename your Calendar Control to avoid possible Errors.
Feb 12 '07 #8
JamesDC
66
I have in the On Load event this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     Me![Calendar1].Value = Format(Now(), "mm/dd/yyyy")
  3. End Sub
  4.  
And when I run my form i get this error:

Run-time error '2448':
You can't assign a value to this object.

I've changed the name of Calendar to Calendar1 so as to avoid the problems with its name, but I still get the error.

When I hit debug on the error it highlights the Me! line of code.

Any ideas on this?
Feb 12 '07 #9
Michael R
176 100+
I have in the On Load event this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     Me![Calendar1].Value = Format(Now(), "mm/dd/yyyy")
  3. End Sub
  4.  
And when I run my form i get this error:

Run-time error '2448':
You can't assign a value to this object.

I've changed the name of Calendar to Calendar1 so as to avoid the problems with its name, but I still get the error.

When I hit debug on the error it highlights the Me! line of code.

Any ideas on this?
As in VBA you write this: "me." does a dropdown menu opens with the different objects of me.? If yes look for calendar there and add to it ".value".
Feb 12 '07 #10
JamesDC
66
When I write in Me., Calendar1 appears in the drop down menu. However I still get the same error when I write it manually.
Feb 12 '07 #11
NeoPa
32,556 Expert Mod 16PB
Try leaving off the .Value part.
Also, Date() should always be available, you may have problems accessing the field as Date on its own though. Use a specific reference (Table.Date) or simply [Date] should work for the field.
Feb 12 '07 #12
NeoPa
32,556 Expert Mod 16PB
...Also, have you tried seeing if you can set the Default property of the Calendar control to :
Expand|Select|Wrap|Line Numbers
  1. =Date()
Feb 12 '07 #13
JamesDC
66
Leaving off the .Value part creates this error:
Run-time error '-2147352567 (80020009)':
You can't assign a value to this object.

When I type in Date() into VB, it automatically removes the brackets from the end, I'm not sure if these means something.

And as far as a default value for the calendar, the only field that would suggest this is the Value property. I tried using Date() and Now() there but it would just erase the box. It needs to be a single date entered into it.
Feb 13 '07 #14
NeoPa
32,556 Expert Mod 16PB
Sorry James, I was just fishing really. I don't use the Calendar control myself much (At all).
The Date() thing makes sense, VBA doesn't like empty () by a function. I use it whenever allowed to document that it's a function I'm dealing with.
Feb 13 '07 #15
JamesDC
66
No problem, they were good suggestions, it's a shame nothing has worked so far.

I've found references to the on Open or on Load codes that were previously mentioned by Michael R and ADezii elsewhere on the internet, but I still can't get past the error that pops up.

Is there an issue about commands in different versions or Access? I'm using the 2003 version.

Also, in the preferences for the calender are areas for Year, Month, and Day. These seem to feed into the box Value that I tried to change already. I tried putting in something like =Date() or =Now() into these sections and I get the message:
VB can't convert the data type of one of the arguments you entered.
You tried to run a VB procedure that executes a method or sets a property of an object.
Check the document's documentation for information on the properties and methods it makes available for Automation operations.

I don't know what it means by the last line for automation.

Any ideas?
Feb 13 '07 #16
JamesDC
66
I've now tried to use in the VB code different variations of:
Expand|Select|Wrap|Line Numbers
  1. Me.Calendar1.Month = Date
  2. Me.Calendar1.Month = Now
  3. Me.Calendar1.Month = Format(Date,"mm")
  4.  
Doing so for Day, Month, and Year, which appear to be the fields that feed into the Value field for the calendar. When I run these nothing happens. There is no error, but the calendar is not effected in any way that I can determine. As soon as I change the .Month to .Value I get the errors again, which says to me there is something wrong with the .Value command... but that's just me.
Feb 13 '07 #17
JamesDC
66
Well, I figured it out, after trying everything :D Here's what I did:

In the event area: 'On Current' I put in the following Event Procedure:

Expand|Select|Wrap|Line Numbers
  1.     Me.Calendar1.Day = Format(Now(), "dd")
  2.     Me.Calendar1.Month = Format(Now(), "mm")
  3.     Me.Calendar1.Year = Format(Now(), "yyyy")
  4.  
My Date() command still doesn't work, so I just formatted the Now() command. I believe .Value will work here too, without throwing the error.

Thanks for the help :)
Feb 13 '07 #18
NeoPa
32,556 Expert Mod 16PB
No problem, they were good suggestions, it's a shame nothing has worked so far.

I've found references to the on Open or on Load codes that were previously mentioned by Michael R and ADezii elsewhere on the internet, but I still can't get past the error that pops up.

Is there an issue about commands in different versions or Access? I'm using the 2003 version.

Also, in the preferences for the calender are areas for Year, Month, and Day. These seem to feed into the box Value that I tried to change already. I tried putting in something like =Date() or =Now() into these sections and I get the message:
VB can't convert the data type of one of the arguments you entered.
You tried to run a VB procedure that executes a method or sets a property of an object.
Check the document's documentation for information on the properties and methods it makes available for Automation operations.

I don't know what it means by the last line for automation.

Any ideas?
I can't help much here I'm afraid as I know very little about this control.
You could consider learning more about the control itself (Use Alt-F11 to switch to the VBA window then F2 to open the object browser window). Navigate to the control and see what type of value the .Value property uses.
I can also explain that Automation usually refers to control of an application from outside. EG. Controlling MS Access from code running within Excel.
Feb 13 '07 #19
JamesDC
66
Wow, I didn't know about the F2 menu in VB (I only started using VB 2 weeks ago...)

Apparently .Value is defined as a Variant. Day, Month, and Year are defined as integers. What a Variant is, I do no, I assume something to do with the formatting of a date...
Feb 13 '07 #20
NeoPa
32,556 Expert Mod 16PB
Just created - as if for you ;)
(VBA Data Types)
Feb 13 '07 #21
in the SOURCE CONTROL of the CALENDAR box propierties
type =Date()
Dec 19 '11 #22

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: cg_news | last post by:
In short, what I am trying to do is, based on a date, calculate the week of year (as described in ISO 8601), then calculate the first and last date in this week period and return them in the format...
0
by: Tim Graichen | last post by:
Hello, I am making use of the Active X calendar control (mscal.Calendar.7) in several places in my main form, with the following code Below is an example of the code I'm using for the...
0
by: Michael Holberton | last post by:
Hi All, I have Access 97, 2000 & 2002 installed in different directories under Win2K Server on a new PC box I built. The Calendar Control on my Date Selector Form is not working and causing...
8
by: Shyguy | last post by:
Is it possible to create a calendar that shows previous input data and also allows for input of new data?
1
by: jim_parent_804 | last post by:
Good morning: I created a data entry form that has been working well, and needed to redesign it. The form is called, and now the first field to be filled in is a date using the MSCAL.Calendar.7...
2
by: Mariano Padilla | last post by:
The calendar control only has the event of SelectionChanged to detect if the user clicks on the calendar. I have 2 calendars on a form, one for arrival date one for departure date. Every time a...
3
by: hellsgate | last post by:
Hey guys, I'm using MSCAL.Calendar.7 to allow the user to select a date and time in an Access application which is used across a network. The application uses Access 2003 as the frontend with...
0
by: mathewgk80 | last post by:
HI all, I am having popup calendar Javascript code. But i dont know how it is connecting to asp.net code.. I am using asp.net,c#.net and also using 3tier architecture with master page.... I...
4
by: gubbachchi | last post by:
Hi all, Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.