Dates checking

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

Guest

I have a table of unavailable dates. When the user chooses a date from a drop down calendar, I want to check that the date they choose is not in the unavailable dates table. If it isn't then I want to do nothing and if it is, I want to give an error message. i have tried some code that I was given which was very kind but something is not working, it also only runs the code if I type the date in - if I choose it from the drop down calendar, it ignores the code that I set to run on the BeforeUpdate event.

Any suggestions? It's driving me nuts - not to mention the fact that the error terms in the the VB I don't understand - such as 'Too few parameters - expected 2' - is this something to do with the date format?

Help! - please :)
 
The basic idea is to use DLookup() to see if the chosen date is in your
table of exclude-dates.

DLookup() returns Null if there is no match. Therefore the expression you
are wanting to check will be something like this:

Not IsNull(DLookup("BadDate", "MyTable", "BadDate = " & Format([SomeDate],
"\#mm\/dd\/yyyy\#"))

Depending on how your receive the dates from the calendar control, you may
need to use the AfterUpdate event and undo the control if the date is no
good, rather than try to do all this in the BeforeUpdate event.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Katherine said:
I have a table of unavailable dates. When the user chooses a date from a
drop down calendar, I want to check that the date they choose is not in the
unavailable dates table. If it isn't then I want to do nothing and if it
is, I want to give an error message. i have tried some code that I was
given which was very kind but something is not working, it also only runs
the code if I type the date in - if I choose it from the drop down calendar,
it ignores the code that I set to run on the BeforeUpdate event.
Any suggestions? It's driving me nuts - not to mention the fact that the
error terms in the the VB I don't understand - such as 'Too few parameters -
expected 2' - is this something to do with the date format?
 
Back
Top