CalendarVB question

Ben2k

Board Regular
Joined
Oct 16, 2002
Messages
77
I'm trying to use the calendarVB control in Access 2000

I have a button to toggle the calendar on and off, the code is

Private Sub Command31_Click()
' display calender
If CalendarVB0.Visible = False Then
CalendarVB0.Visible = True
Else
If CalendarVB0.Visible = True Then
CalendarVB0.Visible = False
End If
End If
End Sub

Then, when a new date is selected I want to update the value of a textbox, so I have this code in the OnUpdated property of the calendar

Private Sub CalendarVB0_Updated(Code As Integer)
' when new date is selected update delivery date textbox
Dim newdeldate As Date
newdeldate = CalendarVB0.Value
DateOfDelivery.Text = newdeldate

End Sub

When run this generates this error

You cant reference a property or method unless the control has the focus

I think it must be because when the form loads the calendars visible property is set to false. But I cant see what the problem is because the calendarvb_updated sub shouldn't run unless a date is clicked on.

How can I fix this?
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Which line of code causes the error?
 
Upvote 0
Try this

Code:
Dim newdeldate As Date

    newdeldate = CalendarVB0.Value

    DateOfDelivery.SetFocus

    DateOfDelivery.Text = newdeldate
 
Upvote 0

Forum statistics

Threads
1,221,773
Messages
6,161,855
Members
451,724
Latest member
sledparty

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top