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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation of Date with Reference to other fields 1

Status
Not open for further replies.

logopolis

Technical User
Oct 10, 2002
59
0
0
ES
I have a date field which I want to validate against four other date field in another table. I have combined the information in a query and sourced the information for the Form from that query. The date entered must be between Date1 and Date2 or Date3 and Date4. If it is not I need a message box to appear saying "Incorrect date range etc". Can anyone help.

John
 
I created an Unbound textbox, formatted as Short Date. Also a command button. Then I typed in a date, click the button to check for validity. Code on the Onclick event of the button is: Or you could put it on the AfterUpdate of the textbox

Private Sub Command12_Click()
If ((Me![DateBox].Value > Me![Date1].Value) And (Me![DateBox].Value < Me![Date2].Value)) Or ((Me![DateBox].Value > Me![Date3].Value) And (Me![DateBox].Value < Me![Date4].Value)) Then
Else
MsgBox "Not in Date Range." & Chr(13) & "Please reenter."
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top