More Newbie Help

  • Thread starter Thread starter tom
  • Start date Start date
T

tom

Have built my first database. This news group has been instrumental!!
I have one more issue, maybe just syntax that I need help with.

This is a database designed to be used by a data entry person. I plan
on eliminating the normal navigation buttons on the menu bar. I have
implemented a "close" button that works just great. Problem is I have
a date field which is indexed with no duplicates (want to prevent data
entry from using duplicate dates). If someone enters an incorrect date
and attempts to advance to the next record using the menu bar a
message pops up telling the user "Invalid Date" and it won't save the
record. However, if you close the form using the Close button (with a
duplicate date)the form closes and doesn't notify the user that the
record wasn't saved. Reading in this forum I implemented the
following code in the date field under the event "exit".

If DCount("[IndexedFieldName]", "TableName") > 1 then

msgbox "Duplicate entry. Record will not be saved."
undo the current record

else

save the record
close the form

I got this code from somewhere is this forum and have struggled to
make it work. I don't have the syntax quite right. Seems to me that
after checking for duplicates and the answer is no then I need a
"goto" [fees] which is the next field on the form.

Can someone help me clean this up? Am I going about this in the right
way? Please note my humble beginnings, no prior VBA experience & first
time user to Access. Therefore I struggle with the least little
syntax issue. So if you can bear with me and show me the specific
syntax I would appreciate it greatly!

Thanks in advance for your help and patience.
 
You could add a table containing only "valid" dates which would restrict the
user's ability to make date entries.
 
Back
Top