Hi everyone!!
I have a continuous form that allows users to select a record and chnage the DATE that the record is assigned to another DATE within the same year. The button is called "Change plan Date Within 2008." The user can select a particular record, click that button and a new small form appears that displays the current Plan Date and a textbox for entering a new Plan Date.
[CODE=VB]'If the New Plan Date is earlier than today's date, this is not allowed
If DateDiff("d", Date, NDate) < 0 Then
MsgBox "You can not enter a Plan Date earlier than today's date."
Exit Sub
End If[/CODE]
I want to make it to where when the user clicks on a record and then clicks that button and types in a new Plan Date and clicks OK, that it won't allow the user to type in a Plan Date that is EARLIER than the one already assigned to that record.
here's my code on that command, but so far it doesn't seem to be working like it should.
[CODE=VB]Private Sub cmdOK_Click()
Dim NDate As String
Dim oDate As String
'Check to see if there is anything typed into the New Plan Date field, if not, close the form
NewPlanDate.Set Focus
If NewPlanDate.Tex t = "" Then
DoCmd.Close acForm, "frmPlanChangeD ate"
Exit Sub
End If
oDate = OldPlanDate.val ue
NDate = NewPlanDate.val ue
'If the New Plan Date is earlier than today's date, this is not allowed
If DateDiff("d", Date, NDate) < 0 Then
MsgBox "You can not enter a Plan Date earlier than today's date."
Exit Sub
End If
'If the user tries to change the year in this form, this is not allowed
If Year(oDate) <> Year(NDate) Then
MsgBox "You can not change the year of the Plan Date here." & vbCrLf & "Please use the " & """" & "Move To" & """" & " buttons to change years."
DoCmd.Close acForm, "frmPlanChangeD ate"
Exit Sub
End If
'Figure out the year and set the Plan Date appropriatly
Forms!frmPlan!f rmPlanList.Cont rols("PlanDate" ).value = NDate
'Close the form
DoCmd.Close acForm, "frmPlanChangeD ate"
End Sub[/CODE]
I have a continuous form that allows users to select a record and chnage the DATE that the record is assigned to another DATE within the same year. The button is called "Change plan Date Within 2008." The user can select a particular record, click that button and a new small form appears that displays the current Plan Date and a textbox for entering a new Plan Date.
[CODE=VB]'If the New Plan Date is earlier than today's date, this is not allowed
If DateDiff("d", Date, NDate) < 0 Then
MsgBox "You can not enter a Plan Date earlier than today's date."
Exit Sub
End If[/CODE]
I want to make it to where when the user clicks on a record and then clicks that button and types in a new Plan Date and clicks OK, that it won't allow the user to type in a Plan Date that is EARLIER than the one already assigned to that record.
here's my code on that command, but so far it doesn't seem to be working like it should.
[CODE=VB]Private Sub cmdOK_Click()
Dim NDate As String
Dim oDate As String
'Check to see if there is anything typed into the New Plan Date field, if not, close the form
NewPlanDate.Set Focus
If NewPlanDate.Tex t = "" Then
DoCmd.Close acForm, "frmPlanChangeD ate"
Exit Sub
End If
oDate = OldPlanDate.val ue
NDate = NewPlanDate.val ue
'If the New Plan Date is earlier than today's date, this is not allowed
If DateDiff("d", Date, NDate) < 0 Then
MsgBox "You can not enter a Plan Date earlier than today's date."
Exit Sub
End If
'If the user tries to change the year in this form, this is not allowed
If Year(oDate) <> Year(NDate) Then
MsgBox "You can not change the year of the Plan Date here." & vbCrLf & "Please use the " & """" & "Move To" & """" & " buttons to change years."
DoCmd.Close acForm, "frmPlanChangeD ate"
Exit Sub
End If
'Figure out the year and set the Plan Date appropriatly
Forms!frmPlan!f rmPlanList.Cont rols("PlanDate" ).value = NDate
'Close the form
DoCmd.Close acForm, "frmPlanChangeD ate"
End Sub[/CODE]
Comment