Results 1 to 6 of 6
  1. #1
    MintChipMadness is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    109

    Date Function AfterInsert

    I am having trouble with one text field on my form. It is not inserting the current date into [EntryDate] when a new record is inserted. The two lines above it work perfectly but the text field bound to EntryDate is left blank. I don't get any errors and I tried all combinations of Enabled and locked data properties. Any help would be greatly appreciated.



    Code:
    Private Sub Form_AfterInsert()
    
    Me.[OldBox#] = DMax("Val([OldBox#])", "[DataEntry]") + 1
    Me.[EnteredBy] = Environ("UserName")
    Me.[EntryDate] = date
    
    End Sub
    Extra Info:
    The form is bound to a query that uses the table with the field [EntryDate]. The field is data type Date/Time.

  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,521
    If that's a copy/paste, it's a concern that date isn't capitalized. Do you have a field by that name by chance? In any event, try


    Me.[EntryDate] = VBA.Date
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    MintChipMadness is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    109
    I did copy/paste the code. When I tried to put just 'Date', I got auto corrected to 'date'. VBA.Date didn't get auto corrected but it still doesn't insert the current date into the field. I didn't get any error with it either.

  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,521
    Is there a textbox on the form with that name? Have you set a breakpoint and followed the action? Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    MintChipMadness is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    109
    I checked that right after posting previously and that is correct. There was a control that had the name 'date'. I adjusted it and everything works now. I apologize for taking up your time with something I should have known to check for.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem, though I'm surprised VBA.Date didn't work. In any case, glad you got it working.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Date Function
    By Zittnat in forum Queries
    Replies: 3
    Last Post: 04-03-2012, 11:19 AM
  2. date function
    By geraldk in forum Forms
    Replies: 13
    Last Post: 12-28-2011, 12:36 PM
  3. Date() function undefined
    By Bruce in forum Queries
    Replies: 4
    Last Post: 07-28-2011, 04:53 PM
  4. Date Function
    By joewhitt in forum Queries
    Replies: 7
    Last Post: 07-17-2011, 07:22 PM
  5. Date Function
    By tmcrouse in forum Queries
    Replies: 2
    Last Post: 12-02-2010, 08:53 AM

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