Disabling New Record

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

Guest

I haven't coded in a while and am feeling a little rusty, but maybe someone
could help me out with this.

I have a form that is linked to a table that uses the date(short) as the
key. I want to be able to identify if the current date
(FormatDateTime(Now(), vbShortDate)) is equal to a tblDate.fldDate entry.
And if so, disable adding a new record from being created (because then it
would error and confuse some of the people who will be using it).

When a user is allowed to enter a new record (date), I have the form forcing
today's date into the text box.

Usage: daily log of work completed, organized by day. Because of this,
users should not be allowed to edit date to smug facts.
 
in the form's Load event procedure, you try something along the lines of

If DCount(1, "tblDate", "fldDate = #" & Date & "#") > 0 Then
Me.AllowAdditions = False
End If

the above assumes that fldDate is a date/time data type.
(since fldDate is a field in the form's RecordSource, there's probably a
more efficient way than using a domain aggregate function, but at this
late/early hour that's all my brain is serving up. <g and yawn>)

hth
 
That's exactly what I was looking for. Might be something more efficeint,
however it works and that's what matters...

Allen
 
Back
Top