Calendar Control

Purdue22

Registered User.
Local time
Today, 14:02
Joined
May 11, 2001
Messages
25
Ok, I think I have just one final question. I posted twice already and have figured out both problems, but I have one more. I have two text boxes that I want to use the calendar event for but I don't know how to arrange the code so that both txt boxes can use the Calendar method.

Code:

Private Sub Date_Received_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Show Calendar and set its date.
Calendar.Visible = True
Calendar.SetFocus


' Set to today if Date Received has no value.
Calendar.Value = IIf(IsNull(Date_Received), Date, Date_Received.Value)


End Sub

Private Sub Calendar_Click()
Date_Received.Value = Calendar.Value
Date_Received.SetFocus
Calendar.Visible = False

End Sub
Private Sub Date_Customer_up_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Show Calendar and set its date.
Calendar.Visible = True
Calendar.SetFocus
' Set to today if Date Customer Up has no value.
Calendar.Value = IIf(IsNull(Date_Received), Date, Date_Received.Value)
End Sub
 
If Not IsNull([FirstTextBox]) Then
Me![SecondTextBox].Value = Calendar.Value
Else
Me![FirstTextBox].Value = Calendar.Value
End if
 
I put the If statment in the Calendar method and it works if the date received field is blank. But when I try to change the date of the date received field it will put the new date in the 'date customer up' txt box.

Code:

Private Sub Date_Received_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Show Calendar and set its date.
Calendar.Visible = True
Calendar.SetFocus


' Set to today if Date Received has no value.
Calendar.Value = IIf(IsNull(Date_Received), Date, Date_Received.Value)


End Sub

Private Sub Calendar_Click()
If Not IsNull([Date Received]) Then
Me![Date Customer up].Value = Calendar.Value
Date_Customer_up.SetFocus
Calendar.Visible = False
Else
Me![Date Received].Value = Calendar.Value
Date_Received.SetFocus
Calendar.Visible = False
End If

End Sub
Private Sub Date_Customer_up_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Show Calendar and set its date.
Calendar.Visible = True
Calendar.SetFocus
' Set to today if Date Customer Up has no value.
Calendar.Value = IIf(IsNull(Date_Received), Date, Date_Received.Value)
End Sub
 
I'm sorry but that is the best that I can do at the moment. Since the Calendar control does not know which field to update you may have to put a message box in the code I gave you that will ask the user if they want to update the field with data. Maybe someone else has a more elegant solution....
 
In this statement:
Calendar.Value = IIf(IsNull(Date_Received), Date, Date_Received.Value)

You have two I's in the If statement "IIf". I'm new, but is that supposed to be that way?
 

Users who are viewing this thread

Back
Top Bottom