DateAdd Function.

Results 1 to 2 of 2

Thread: DateAdd Function.

  1. #1
    Join Date
    Dec 1969

    Default DateAdd Function.

    Hi,<BR>I have an access field which I need to default to a date field in the future. Im trying to use VB to do this. If you take a look at my code below you might get the idea what Im trying. If anyone can tell me how to do it I would be really grateful...<BR><BR>DATEAUDITNEXTDUE ---DEFAULT VALUE =DateAdd("m","12",Date()) ---This works...but I need.<BR>DATEAUDITNEXTDUE ---DEFAULT VALUE =DateAdd("m", FieldCalledFrequency, FieldCalledDateofAudit)<BR><BR>Basically then what I need is that if FieldCalledFrequency is populated with a 2 well then 2 months will be added to FieldCalledDateofAudit and inserted as the default field DATEAUDITNEXTDUE ! However access doesnt like my syntax...<BR>Is it possible ?<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: DateAdd Function.

    What does VB have to do with this???<BR><BR>You can&#039;t set a default value of a field to depend on the values of other fields in the same record. This only makes sense! It would be SO EASY to create a circular dependency (in other words, an infinite loop) if this kind of stuff was allowed.<BR><BR>But, instead, you could do this:<BR><BR>Set the default value of DATEAUDITNEXTDUE to NULL.<BR><BR>Then do the INSERT as usual:<BR>INSERT INTO table ....<BR><BR>And follow it up with<BR>UPDATE table SET DATEAUDITNEXTDUE = DateAdd(&#039;m&#039;,freq,dateofaudit) WHERE DATEAUDITNEXTDUE = NULL<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts