Hello
I have a data base to control the loan dates of plants. On a table, I have a field with the Send date of the plants and the Predicted date of return of the plants. I have some code so that when I introduce a date in the Send date field, on the Predicted date it appears the Send date plus 6 months. This works fine if there is no date in the predicted date field.
But if there is a value in the predicted date (is not null), and I change the send date, I have a code that warns me that the predicted date is going to change. This appears with a msgbox with a yes/no option. If I click yes, the predicted date adds 6 months. The problem is that when I click no, the computer adds 6 months to the predicted date when what I want is for the dates to stay the same. It would be like as if I had cancelled the changes.
Here is the code I have for this. Can somebody help me with the code for the no option, so that if I select no, nothing changes.
Private Sub Send_date_AfterUpdate()
If IsNull(Me.Predicted_date) Then
GoTo ver
Else
GoTo wer
End If
wer:
If MsgBox("You are about to change the Predicted date." _
& vbCrLf & vbCrLf & "Do you wish to continue?" _
, vbYesNo, "Change predicted date") = vbYes Then
Me.Predicted_date = DateAdd("m", 6, Me.Send_date.Text)
End If
ver:
Me.Predicted_date = DateAdd("m", 6, Me.Predicted_date.Text)
End Sub
Thanks in advance for your help. Sorry for asking these questions that may seem quite basic but I’m learning by my self.
I have a data base to control the loan dates of plants. On a table, I have a field with the Send date of the plants and the Predicted date of return of the plants. I have some code so that when I introduce a date in the Send date field, on the Predicted date it appears the Send date plus 6 months. This works fine if there is no date in the predicted date field.
But if there is a value in the predicted date (is not null), and I change the send date, I have a code that warns me that the predicted date is going to change. This appears with a msgbox with a yes/no option. If I click yes, the predicted date adds 6 months. The problem is that when I click no, the computer adds 6 months to the predicted date when what I want is for the dates to stay the same. It would be like as if I had cancelled the changes.
Here is the code I have for this. Can somebody help me with the code for the no option, so that if I select no, nothing changes.
Private Sub Send_date_AfterUpdate()
If IsNull(Me.Predicted_date) Then
GoTo ver
Else
GoTo wer
End If
wer:
If MsgBox("You are about to change the Predicted date." _
& vbCrLf & vbCrLf & "Do you wish to continue?" _
, vbYesNo, "Change predicted date") = vbYes Then
Me.Predicted_date = DateAdd("m", 6, Me.Send_date.Text)
End If
ver:
Me.Predicted_date = DateAdd("m", 6, Me.Predicted_date.Text)
End Sub
Thanks in advance for your help. Sorry for asking these questions that may seem quite basic but I’m learning by my self.