Results 1 to 7 of 7
  1. #1
    Access_Novice123 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    9

    Auto Fill with Date and Time

    Hi, I'm new to Access and I'm trying to build a database to track the progress of document editing. I've made a form that will be filled out at different stages throughout the document's progression. The form contains drop downs and date/time stamps. There are different sections to be filled out at different times For instance:


    Opened By -- Opened date, opened time
    Content Review By--review date, review time
    PDF By--PDF date, PDF time
    etc.

    What I'm trying to do is have the date and time fields fill automatically when the respective "Done by" field is filled in. I am using the code =IIf([Opened By]=True,[Opened Date]=Now()) in the date fields but it is not responding. Alternatively, if i set all the date time fields to default values Now() in the design view of the table of origin, all the fields fill at once instead of each stage being filled separately.

    Is there a way to fix this? Thanks for helping a Newbie!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    VBA code in the after update event of the Opened By field (inadvisable to have spaces in names):

    Code:
    If Me.[Opened By] = True Then
      Me.[Opened Date] = Now()
    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Access_Novice123 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    9
    Hi there,

    Thanks for your reply. Unfortunately nothing happens when I try to put in this code.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Did you put it in the VBA editor in the correct event?

    http://www.baldyweb.com/FirstVBA.htm

    Has code been enabled or is the db in a trusted location?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    not sure what you're testing for but I'm assuming it's a value existing in opened by, but you would also have to check to see if the opened date is already populated, in other words you wouldn't want to overwrite a value if it was already present in opened date

    Code:
    if not isnull([Opened by]) and isnull([opened date]) then
        [opened date] = now()
    endif

  6. #6
    Access_Novice123 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    9
    Thank you rpeare! I have no idea what that code means but it worked perfectly hah! Thank you so much!!

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    isnull checks to see if a field is empty so conversely not isnull makes sure a field has *something* in it. You were checking for a TRUE value on a field that could not possibly yield a true/false or an expression that could be evaluated as true or false.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Auto fill date into unbound text box
    By data808 in forum Programming
    Replies: 4
    Last Post: 02-26-2014, 09:21 PM
  2. Auto Fill a date in a field
    By SJJ in forum Access
    Replies: 1
    Last Post: 02-17-2014, 02:39 PM
  3. Lock field after auto date fill
    By DCV0204 in forum Forms
    Replies: 4
    Last Post: 11-25-2013, 08:53 AM
  4. Auto fill a due date column in a query
    By Dexter in forum Queries
    Replies: 7
    Last Post: 02-23-2011, 07:00 AM
  5. Replies: 0
    Last Post: 02-26-2009, 03:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums