Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access: Change event not working after inserting calendar control

Status
Not open for further replies.

ShabanaHafiz

Programmer
Jun 29, 2003
72
PK
I am using MS Office Access 2003.

I created a Pop-Up Calendar on my form as follows (the form is bound to a table):

1. Insert -> ActiveX Control -> Calendar Control 11.0
2. Calendar Control (Name: Calendar; Visible No)
3. Added the following code to the MouseDown event of the cboDateOfTravel combo box:

Code:
Private Sub cboDateOfTravel_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Calendar.Visible = True
Calendar.SetFocus
Calendar.Value = IIf(IsNull(cboDateOfTravel), Date, cboDateOfTravel.Value)

End Sub

4. Added the following code to the Click event of the Calendar control:

Code:
Private Sub Calendar_Click()

cboDateOfTravel.Value = Calendar.Value
cboDateOfTravel.SetFocus
Calendar.Visible = False

End Sub

Before inserting the calendar control, I wrote the following in the Change event of cboDateOfTravel:

Code:
Private Sub cboDateOfTravel_Change()
EnableControls False, True, True, False
End Sub

The change event was firing. But after inserting the calendar control, Change event for cboDateOfTravel does not fire when the date is changed and Combo Box gets a new value.
 
I think the Change event is fired by manual change, not change made by code.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks.

I shifted the statement to Enter event and it worked. Now for any change in cboDateOfTravel, EnableControls Subroutine is called.

Code:
Private Sub cboDateOfTravel_Enter()
EnableControls False, True, True, False
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top