472,353 Members | 2,236 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 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 20217
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,832 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,832 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,511 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,511 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,511 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,511 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,511 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...
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...
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...
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...
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...
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...
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...
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...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

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.