Results 1 to 8 of 8
  1. #1
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276

    Code Help For Fixing Date & Time

    The following code uses the transaction date & time. I want it to use the current system date & time instead. How do I do that.

    Private Sub Supervised_By_AfterUpdate()
    Me.SupPurDate = Date
    Me.SupPurEntryTime = Time


    Me.Requery
    End Sub

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Me.SupPurDate = Date()
    Me.SupPurEntryTime = Time()
    These would be the default values.
    HTH

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    It sounds like you've got fields named date and time, which isn't a good idea. You may need to be explicit:

    VBA.Date
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    accedeholdings is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Sep 2014
    Location
    Hackney, South Australia
    Posts
    17
    Your code is kinda complex. You might want to delegate a separate function for time and date then try to simplify it from there.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    @Accedeholdings, why would do you say the code is complex? Don't think it can get much simpler.

    As Paul said, Date and Time are reserved words and should not use reserved words as field names. Maybe VBA was pulling from the fields but there are times that reserved word field names could cause unexpected results.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  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,641
    Quote Originally Posted by accedeholdings View Post
    Your code is kinda complex. You might want to delegate a separate function for time and date then try to simplify it from there.
    Complex? Based on other posts, are you just spamming the forum?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    VBA.Date
    VBA.Time

    Worked Thx

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    No problem.
    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. Replies: 11
    Last Post: 07-20-2014, 06:22 PM
  2. Help Needed Fixing the Code
    By aamer in forum Access
    Replies: 8
    Last Post: 03-01-2014, 04:55 PM
  3. Help fixing a code to change password programatically
    By smartflashes in forum Programming
    Replies: 3
    Last Post: 01-19-2012, 10:20 PM
  4. Date/Time code
    By JayX in forum Access
    Replies: 13
    Last Post: 12-15-2011, 03:31 PM
  5. Fixing run-time error 3049
    By kthakk4 in forum Programming
    Replies: 1
    Last Post: 09-30-2011, 07:37 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