By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,164 Members | 1,019 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,164 IT Pros & Developers. It's quick & easy.

problem with calender object

P: 5
Hey everyone,
I'm having trouble manipulating the calender object in vba. I have a form with a Microsoft calender control object 9.0 embedded in it. All I want to do is upon opening this form, set the date to the value I pull from a table. This field I pull from is a date field formated "mm/dd/yyyy" here is the code in question:

calStartDate.Value = Rs1("Start Date")

when hovering over each of these values while in break mode (I know not the right terminology) I get "1/1/2007" for calstartdate.value and "1/27/2007" for Rs1("Start Date") but upon stepping to the next line the value of calStartDate.value doesn't change at all. Starting to get real frustrating. Anybody have any idea why this is happening?
thanks,
Lobster
Jan 5 '07 #1
Share this Question
Share on Google+
6 Replies


nico5038
Expert 2.5K+
P: 3,072
I prefer to use the minicalendar control from http://www.mvps.org/access/forms/frm0050.htm
(Excellent site with much info and samples)

Idea ?

Nic;o)
Jan 6 '07 #2

missinglinq
Expert 2.5K+
P: 3,532
It would probably help if we could see your code. What exactly is this Rs1("Start Date") you're trying to assign to the calendar?
Jan 6 '07 #3

100+
P: 1,646
Hey everyone,
I'm having trouble manipulating the calender object in vba. I have a form with a Microsoft calender control object 9.0 embedded in it. All I want to do is upon opening this form, set the date to the value I pull from a table. This field I pull from is a date field formated "mm/dd/yyyy" here is the code in question:

calStartDate.Value = Rs1("Start Date")

when hovering over each of these values while in break mode (I know not the right terminology) I get "1/1/2007" for calstartdate.value and "1/27/2007" for Rs1("Start Date") but upon stepping to the next line the value of calStartDate.value doesn't change at all. Starting to get real frustrating. Anybody have any idea why this is happening?
thanks,
Lobster
Hi what happens if you replace the recordset value with a literal?
Expand|Select|Wrap|Line Numbers
  1. calStartDate.Value = "1/1/2008"
Jan 6 '07 #4

MSeda
Expert 100+
P: 159
Your'e problem seemed pretty straight foward so I built a test form as you described and I found this. the code did not function in the on open event as you stated. so I moved it to the On Load event. It worked! I've been told the on load event occurs after on open. perhaps some of the experts can give a more in depth description of the differences between the two.

Hope this helps,
Megan
Jan 7 '07 #5

missinglinq
Expert 2.5K+
P: 3,532
The sequence of events when initializing a form is (per Access Help)


Open [font=Symbol][/font] Load [font=Symbol][/font] Resize [font=Symbol][/font] Activate [font=Symbol][/font] Current


I believe I've read somewhere that the Open event is the actual initializing of the physical framework, if you will, of the form, while the Load event is the actual "loading" of the Record Source, assuming the form is bound. If this is correct, it would explain why the code fails during the Open event but works during the Load event, when the Record Source has been loaded. I never use the OnOpen event, so never even gave that any thought!


Good catch, Megan!
Jan 7 '07 #6

P: 5
Thanks everyone,
I moved it over to the on load event and that fixed it. My guess is the calender object was not fully initialized or something to that effect until after the on open event. The form was not bond to any recordset, but rather Rs1 was a recordset I created in code:
Expand|Select|Wrap|Line Numbers
  1.     Set Rs1 = Db.OpenRecordset("tblAccountDeliveryDays")
  2.     Rs1.MoveFirst
  3.  
  4.     Do While Not Rs1.EOF
  5.         If Rs1("Account number") = intAccountNumber Then
  6.             Exit Do
  7.         End If
  8.         Rs1.MoveNext
  9.     Loop
  10.     chkMonday = Rs1("Monday")
  11.     chkTuesday = Rs1("Tuesday")
  12.     chkWednesday = Rs1("Wednesday")
  13.     chkThursday = Rs1("Thursday")
  14.     chkFriday = Rs1("Friday")
  15.     chkSaturday = Rs1("Saturday")
  16.     chkSunday = Rs1("Sunday")
  17.     txtSpecialNotes = Rs1("Special Notes")
  18.     cmbDeliveryQuadrant = Rs1("Delivery Quadrant")
  19.     calStartDate.Value = Rs1("Start Date")
  20.  
  21.     Rs1.Close
  22.     Db.Close
So I think it has more to do with the actual object, but like I said problem solved.
thanks,
Lobster
Jan 7 '07 #7

Post your reply

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