Results 1 to 6 of 6

Thread: Default values in Access 2000

  1. #1
    Join Date
    Nov 2002
    Location
    DE
    Posts
    246

    Default values in Access 2000

    Hi all

    I am trying to assign a default value to a field in an Access table. The default value is generated in a function which is declared as PUBLIC in a module.

    So far so good. When trying to assign this function as the default value to a field in a table in the same db, Access does not recognize the function.

    However in a query or in a form I can reference and call the function without any problem.

    Can anybody give me a hint if and how the function can be used inside the table definition?

    Thanks in advance
    Andi

  2. #2
    Join Date
    Jan 2003
    Location
    UK
    Posts
    277
    can you assign the value the function generates to the field default property from within code when your application starts up ?

  3. #3
    Join Date
    Nov 2002
    Location
    DE
    Posts
    246
    No, the users enter new records into the table and there are some fields (eg timestamp and NTuser) which I want to fill automatically. The timestamp is not a problem, because I can now() is an inbuild function which can be assigned a the default value of a table field. The NTuser is determined from a VB function which, although defined as Public is not usable as the default value.

    We worked around the problem by designing a form for the data entry, where it is no problem to assign a VB function as the default value of a field. However I do not really understand why the default value of a form field is handled different than the default value of a table.

    Anyway thanks for spending time on my post :-)

  4. #4
    Join Date
    Jul 2005
    Location
    Manchester, UK
    Posts
    7
    Just had a thought andi - is the function you've created in the same project as your table? What I mean is, the function will not work if it's in a project where the table that calls it is linked. er...am I making sense?

  5. #5
    Join Date
    Nov 2002
    Location
    DE
    Posts
    246
    Good thought, but unfortunately not applicable because it is a single mdb containing tables and code

  6. #6
    Join Date
    Aug 2005
    Posts
    29
    if u r trying to get the environment variable username from that VB code, try setting default value as
    =ENVIRON("USERNAME")

    It gives the username from XP.

Posting Permissions

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