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
21 20217
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
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?
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 - - Private Sub Form_Open(Cancel As Integer)
right here
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.
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: - Private Sub Form_Load()
-
Me![Calendar1].Value = Date
-
End Sub
As previously indicated, assuming your Calendar Name is Calendar1 then place this code in the Form's Load Event - not Open: - Private Sub Form_Load()
-
Me![Calendar1].Value = Date
-
End Sub
Also, I forgot to mention, choose 'code builder' while pressing the "..." button from On Open event line in the propreties box.
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.
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.
I have in the On Load event this: -
Private Sub Form_Load()
-
Me![Calendar1].Value = Format(Now(), "mm/dd/yyyy")
-
End Sub
-
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?
I have in the On Load event this: -
Private Sub Form_Load()
-
Me![Calendar1].Value = Format(Now(), "mm/dd/yyyy")
-
End Sub
-
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".
When I write in Me., Calendar1 appears in the drop down menu. However I still get the same error when I write it manually.
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.
NeoPa 32,511
Expert Mod 16PB
...Also, have you tried seeing if you can set the Default property of the Calendar control to :
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.
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.
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've now tried to use in the VB code different variations of: -
Me.Calendar1.Month = Date
-
Me.Calendar1.Month = Now
-
Me.Calendar1.Month = Format(Date,"mm")
-
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.
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: -
Me.Calendar1.Day = Format(Now(), "dd")
-
Me.Calendar1.Month = Format(Now(), "mm")
-
Me.Calendar1.Year = Format(Now(), "yyyy")
-
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 :)
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.
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...
in the SOURCE CONTROL of the CALENDAR box propierties
type =Date()
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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?
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
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.
...
|
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...
|
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...
|
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...
|
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...
|
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....
| |