Hi Robin,
I think I found the problem. Try this code exactly as it is. You will need to use this to completely replace what you have.
Public Function NextAnniversary(datChartered As Date) As Date
Dim intMonth As Integer, intDay As Integer, intYear As Integer
intMonth = Month(datChartered)
intDay = Day(datChartered)
intYear = Year(Date)
If (intMonth > Month(Date)) Or _
((intMonth = Month(Date)) And (intDay < Day(Date))) Then
intYear = intYear + 1
End If
NextAnniversary = DateSerial(intYear, intMonth, intDay)
End Function
Kind Regards,
Pat Wood
Gaining Access Technologies Founder
http://gainingaccess.net
Microsoft Access and SQL Azure Information Center for Developers:
http://gainingaccess.net/SQLAzure/AccessAndSQLAzureInfo.aspx
--- In MS_Access_Professionals@yahoogroups.com, Robin Chapple wrote:
>
> Thanks again Pat,
>
> Public Function NextAnniversary(datChartered As Date) As Date
>
> Dim intMonth As Integer, intDay As Integer, intYear As Integer
>
> intMonth = Month(datChartered)
>
> intDay = Day(datChartered)
>
> intYear = Year(Date)
>
> If (intMonth Month(Date)) Or _
>
> ((intMonth = Month(Date)) And (intDay Day(Date)) Then
>
> intYear = intYear + 1
>
> End If
>
> NextAnniversary = DateSerial(intYear, intMonth, intDay)
>
> End Function
>
> Call that from a query on your table like this:
>
> Anny: NextAnniversary([DateChartered])
>
> Regards,
>
> Robin
>
> At 31/01/2013 04:34 PM, you wrote:
> >Hi Robin,
> >
> >Can you post the original Function?
> >
> >Pat
> >
> >--- In MS_Access_Professionals@yahoogroups.com, Robin Chapple wrote:
> > >
> > > Well done Pat,
> > >
> > > That found the function but I cannot edit it to give 2013 instead of 2014.
> > >
> > > From February onwards the next anniversary will be in 2013 but all
> > > are returning 2014.
> > >
> > > I have edited intYear = intYear + 1
> > >
> > > to
> > >
> > > intYear = intYear
> > >
> > > and
> > >
> > > intYear = intYear -1
> > >
> > > Without the change showing.
> > >
> > > I have even edited
> > >
> > > NextAnniversary = DateSerial((intYear - 1), intMonth, intDay)
> > >
> > > to
> > >
> > > NextAnniversary = DateSerial((intYear - 2), intMonth, intDay)
> > >
> > > without a change.
> > >
> > > 2014 seems to be set in concrete!
> > >
> > > Regards,
> > >
> > > Robin
> > >
> > > At 31/01/2013 04:05 PM, you wrote:
> > > >Hi Robin,
> > > >
> > > >Don't worry about seeing blank until you do the search for the name
> > > >of the Function according to my instructions I gave in an earlier
> > > >post. If you have the name right and followed my instructions you
> > > >will find the Function.
> > > >
> > > >If that does not work then perhaps you have the name of the Function
> > > >wrong. You can then search for the text below which should be in
> > your Function:
> > > >
> > > >intYear = intYear + 1
> > > >
> > > >Kind Regards,
> > > >Pat Wood
> > > >Gaining Access Technologies Founder
> > > >http://gainingaccess.net
> > > >Microsoft Access and SQL Azure Information Center for Developers:
> > > >http://gainingaccess.net/SQLAzure/AccessAndSQLAzureInfo.aspx
> > > >
> > > >
> > > >--- In MS_Access_Professionals@yahoogroups.com, Robin Chapple wrote:
> > > > >
> > > > >
> > > > > Thanks for your persistence.
> > > > >
> > > > > The function is working but it gives the year as 2014 and I need
> > > > it to be 2013.
> > > > >
> > > > > So the answers to your queries must be 'Yes'.
> > > > >
> > > > > With the query on the worksapce Alt F11 gives me blank pages.
> > > > >
> > > > > Cheers,
> > > > >
> > > > > Robin
> > > > >
> > > > > At 31/01/2013 03:40 PM, you wrote:
> > > > > >Hi Robin,
> > > > > >
> > > > > >Did you try searching as I laid out?
> > > > > >
> > > > > >If so, are you sure you saved the Function?
> > > > > >
> > > > > >And are you using the database in which you created the Function?
> > > > > >
> > > > > >
> > > > > >Kind Regards,
> > > > > >Pat Wood
> > > > > >Gaining Access Technologies Founder
> > > > > >http://gainingaccess.net
> > > > > >Microsoft Access and SQL Azure Information Center for Developers:
> > > > > >http://gainingaccess.net/SQLAzure/AccessAndSQLAzureInfo.aspx
> > > > > >
> > > > > >
> > > > > >--- In MS_Access_Professionals@yahoogroups.com, Robin Chapple wrote:
> > > > > > >
> > > > > > >
> > > > > > > Thanks Pat,
> > > > > > >
> > > > > > > I had tried that and once again all I get is blank pages!
> > > > > > >
> > > > > > > Cheers,
> > > > > > >
> > > > > > > Robin
> > > > > > >
> > > > > > > At 31/01/2013 02:49 PM, you wrote:
> > > > > > > >Hi Robin,
> > > > > > > >
> > > > > > > >That's OK. Try pressing the Alt and F11 keys at the same time.
> > > > > > > >
> > > > > > > >Kind Regards,
> > > > > > > >Pat Wood
> > > > > > > >Gaining Access Technologies Founder
> > > > > > > >http://gainingaccess.net
> > > > > > > >Microsoft Access and SQL Azure Information Center for Developers:
> > > > > > > >http://gainingaccess.net/SQLAzure/AccessAndSQLAzureInfo.aspx
> > > > > > > >
> > > > > > > >
> > > > > > > >--- In MS_Access_Professionals@yahoogroups.com, Robin
> > Chapple wrote:
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Thanks Pat,
> > > > > > > > >
> > > > > > > > > I cannot even find the "" window where you work with
> > the code "".
> > > > > > > > >
> > > > > > > > > Woe is me! Sackcloth and ashes!!!
> > > > > > > > >
> > > > > > > > > Cheers,
> > > > > > > > >
> > > > > > > > > Robin
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > At 31/01/2013 12:37 PM, you wrote:
> > > > > > > > > >Hi Robin,
> > > > > > > > > >
> > > > > > > > > >You can do a search for NextAnniversary was it? In the
> > > > window where
> > > > > > > > > >you work with the code on the Menu click "Edit" and then
> > > > "Find" and
> > > > > > > > > >enter NextAnniversary in the "Find What:" box at the
> > top of the
> > > > > > > > > >dialog that opens and then make sure that "Current Project" is
> > > > > > > > > >selected and then click "Find Next". Keep clicking "Find
> > > > Next" until
> > > > > > > > > >you see the Function.
> > > > > > > > > >
> > > > > > > > > >Kind Regards,
> > > > > > > > > >Pat Wood
> > > > > > > > > >Gaining Access Technologies Founder
> > > > > > > > > >http://gainingaccess.net
> > > > > > > > > >Microsoft Access and SQL Azure Information Center
> > for Developers:
> > > > > > > > > >http://gainingaccess.net/SQLAzure/AccessAndSQLAzureInfo.aspx
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >--- In MS_Access_Professionals@yahoogroups.com, Robin
> > > > Chapple wrote:
> > > > > > > > > > >
> > > > > > > > > > > My apology for being a 'lame duck'.
> > > > > > > > > > >
> > > > > > > > > > > John Viescas has taken me step by step through adding
> > > > a function to
> > > > > > > > > > > my database. It works as planned with one exception
> > > > and I need to
> > > > > > > > > > > edit one criteria.
> > > > > > > > > > >
> > > > > > > > > > > How do I get back to the function to edit it? I have
> > > > investigated
> > > > > > > > > > > everything that looks possible without success. The
> > > > Microsoft help
> > > > > > > > > > > page was no help.
> > > > > > > > > > >
> > > > > > > > > > > Your advice is welcome.
> > > > > > > > > > >
> > > > > > > > > > > Robin Chapple
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >------------------------------------
> > > > > > > > > >
> > > > > > > > > >Yahoo! Groups Links
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >------------------------------------
> > > > > > > >
> > > > > > > >Yahoo! Groups Links
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >------------------------------------
> > > > > >
> > > > > >Yahoo! Groups Links
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > >
> > > >------------------------------------
> > > >
> > > >Yahoo! Groups Links
> > > >
> > > >
> > > >
> > >
> >
> >
> >
> >
> >------------------------------------
> >
> >Yahoo! Groups Links
> >
> >
> >
>
Reply via web post | Reply to sender | Reply to group | Start a New Topic | Messages in this topic (12) |
Tidak ada komentar:
Posting Komentar