Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Location
    Arizona
    Posts
    75

    Unanswered: Events on Creating a New Record.

    I have to admit, I suck at Access.

    I am working on an old Access system which now ties to a SQL Server Database. I am in the process of making a replacement system but in the mean time I have to support the old one.

    The Issue is that we have numbers that are generated based on the Fiscal Year. Some where in the code some one has hard coded the years and I need to update it. I checked for a Trigger (which is how I would have done it) and found none. It seems that the programer did it on some kind of on insert event in the VBA code. I looked at the VBA behind the NEW button we have on the form and all it does is the following.

    DoCmd.GoToRecord , , acNewRec

    So there is code some where that is doing the number generation when a record is added. I want to find this code, remove it so that I can code a trigger which is the proper way of doing it. The problem is I have no idea where to look. Can some one help?

    Thanks.

  2. #2
    Join Date
    Apr 2004
    Location
    Arizona
    Posts
    75
    Never mind, I found it. It turns out they setup an UDF and used a Default Value on the field.

    CREATE FUNCTION dbo.GetFiscalYear
    (
    @Date DateTime
    )
    RETURNS INT
    AS
    BEGIN
    -- Declare the return variable here
    DECLARE @Result INT


    SET @Result = DatePart(yy,@Date)
    IF DatePart(m,@Date) = 7
    SET @Result = @Result + 1
    RETURN @Result

    END

    I changed the "=" to ">=" and problem solved. Thanks for listening.

Posting Permissions

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