Re: Still need help incrementing a number after resetting it daily to 1

Tech-Archive recommends: Fix windows errors by optimizing your registry



Michael wrote:
> Thanks Rick,
> The form is a single view and only one computer will access this
> form, but when I add the code to the default in the properties, I
> get the same error. I tried to add the other code to the before
> update, and I only get a 0 in the NPedana field. I tried to change
> the date on my computer.. but still get a "0"

In these cases you need to "divide and conquer". Open the immediate window
(Control-G) and type...

?Nz(DMax("NPedana", "Registro Entrata", "Day(Del)=Day(Date())"), 0) + 1
<Enter>

....and see if you get an error or the correct response. If you don't get
the correct response strip something out of the expression to simplify it
and try again. For example, I would first eliminate the WHERE clause from
the DMax() to see if that is the problem...

?Nz(DMax("NPedana", "Registro Entrata"), 0) + 1 <Enter>

Does this work? If so, then you know that the WHERE clause is the problem.
Actually in looking at this I see a different problem anyway. You should
not be using Day() because that just returns the day of the month which will
not work. You need to compare the actual dates. What should work is...

?Nz(DMax("NPedana", "Registro Entrata", "DateValue(Del)=Date()"), 0) + 1
<Enter>

If the field [Del] has no time component stored then the DateValue()
function would not be required and you could just use...

?Nz(DMax("NPedana", "Registro Entrata", "Del = Date()"), 0) + 1 <Enter>

Be careful not to be confused by formatting here. How you have Del
formatted has no bearing on whether a time component is stored or not. It
has to do with whether it is populated by using Date() or Now(). If there
is no time vaue stored (actually a time of midnight) then the expression
without the DateValue() funstion will be more efficient. You should also
apply an index to this field.

Try the above and see if you have any success.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


.



Relevant Pages

  • Not finding records
    ... If the data in your StartDate column contains a non zero ... time component you will not get a match. ... Formatting the ...
    (microsoft.public.access.tablesdbdesign)
  • Re: showing only date not time
    ... run an Update query and use DateValue() to lose the time component. ... Allen Browne - Microsoft MVP. ...
    (microsoft.public.access.forms)
  • Re: A VBA function to give serial date for date and time?
    ... Assuming you mean your date is text (a string), use the CDate or DateValue ... DateValue won't include the time component, ...
    (microsoft.public.excel.programming)
  • Re: Query for date
    ... but to query for a certain date, you can use the criterion like: ... If you have non-zero time component in, ... using DateValue() and hence my preference is the range rather than ... > I would like to filter by query for certain date. ...
    (microsoft.public.access.queries)
  • Re: A VBA function to give serial date for date and time?
    ... and not a string. ... > Assuming you mean your date is text, use the CDate or DateValue ... > DateValue won't include the time component, ... >>Is there a VBA function which would convert a date into a serial number, ...
    (microsoft.public.excel.programming)