date field cannot be more than 1 month from prior date field crite

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I am working on a form and i have a combo box with a selection of 'Temp' and
'Perm'. I also have two fields , 'effdt' and 'enddt'.When this combo is on
'Temp'
I would like to set a constraint on the 'enddt' ,where the 'enddt' cannot
be set no more than 31 days, or 1 month from the 'effdt'
( ie--> Combobox='Temp', effdt='01-01-2004', and 'enddt' <= 31 days from
'effdt')

Thanks
 
Hi,
I am working on a form and i have a combo box with a selection of 'Temp' and
'Perm'. I also have two fields , 'effdt' and 'enddt'.When this combo is on
'Temp'
I would like to set a constraint on the 'enddt' ,where the 'enddt' cannot
be set no more than 31 days, or 1 month from the 'effdt'
( ie--> Combobox='Temp', effdt='01-01-2004', and 'enddt' <= 31 days from
'effdt')

Thanks

Use the Form's BeforeUpdate event to check this:

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Me!combobox = "Temp" Then
If Me!EndDt > DateAdd("m", 1, Me!EffDt) Then
MsgBox "Temp only allows one month", vbOKOnly
Cancel = True
End If
End If
End Sub

You may also want to check for NULL in EffDt and/or EndDt if they are
not required fields.

John W. Vinson[MVP]
 
Back
Top