I have an Access form for adding records. One of the fields on the form requires a date to be entered. When the user presses the command button on the form to add a record, the date entered in the textbox is checked against a table I have that lists invalid dates.
That table has two fields. Field1 contains the invalid date value. Field2 contains a description of why it is invalid.
So, for example, a record in the table may look like this:
9/19/2016 Closed for renovations
To check if an invalid date is selected, I currently have the following code:
If CBool(DCount("*", "MyDatesTable", "[Invalid_Date] = #" & Format(Forms![MyForm]![MyDateTextbox].Value, "yyyy\/mm\/dd") & "#")) Then
MsgBox "Invalid Date Selected"
What I'd like to be able to is, in addition to the message box indicating an invalid date was selected, I would also like to display why it's invalid. Therefore, if a matching date is found in the table with what was entered in the textbox, I'd like to be able to display the contents of Field2 for that record.
So, if 9/19/2016 was selected (and presuming it's in the table as an invalid date due to business having been closed for renovations), I'd like to be able to display Field2's contents (i.e. "Closed for renovations") in the messagebox. I don't care where in the messagebox it is displayed just as long as it is displayed. Thank you.