Results 1 to 7 of 7
  1. #1
    cwwaicw311 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    75

    VB coding to show current date n time in access form

    I'm new to VB in access and wandering if there is VB coding to show time n date in access form. Here is the problem i having, i making a simple inventory tracking system, and when the staff key in their ID at the same time the time n date would appear in the time and date column. This could make sure that the time n date would be accurate when the inventory is taken out.


  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The Now() Function returns the current Date and Time.

  3. #3
    cwwaicw311 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    75
    thank... but how do i implement this function into the vb script page in the access form...??

  4. #4
    maximus's Avatar
    maximus is offline Expert
    Windows XP Access 2003
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Well let me get this straight you have a form which is probably used for recording issue of inventory, and on that form you have a field that you want to record the time at which the inventory is issued. You want the time (current time and date) to be automatically recorded when you fill up the form and save the data. If this is your criteria here is my solution:

    You need to create a command button. When you do so the Wizard opens. Go to Record Operations. Select Save Record and create the button. The Code marked red will be created automatically for you.

    Now I have a form in which I have a field called Date. In this field I will record the current date and time. Right Click the Save Command Button that you have created go to the Click Event and open the Vb Code. Add the Line that is in black in the code. This will do the trick. Remember to select general Date format when you are designing the table.

    Private Sub Command6_Click()
    On Error GoTo Err_Command6_Click


    Me.Date = Now()
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

    Exit_Command6_Click:
    Exit Sub

    Err_Command6_Click:
    MsgBox Err.Description
    Resume Exit_Command6_Click

    End Sub


    Please mark this thread as solved if it solves your problem.

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It is really not a good idea to have a field named Date since it is a reserved word.
    http://www.allenbrowne.com/AppIssueBadWord.html

  6. #6
    maximus's Avatar
    maximus is offline Expert
    Windows XP Access 2003
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Rural Guy is right it is no a good idea to use a reserved word as a field name. But the point is just type use the code with the field name that you have in your data base.

  7. #7
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I am just curious whether you were able to solve your problem? If yes please mark this thread to be solved. This will help others who may be facing a similar problem and wants quick solution.

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

Similar Threads

  1. Current Date Error
    By McFly in forum Database Design
    Replies: 4
    Last Post: 02-04-2010, 09:08 AM
  2. Showing date and time when importing to access
    By timpepu in forum Import/Export Data
    Replies: 0
    Last Post: 05-07-2009, 07:13 AM
  3. Access Runtime 2007 Date Time Picker Vista not working
    By sailinxtc in forum Programming
    Replies: 0
    Last Post: 09-17-2008, 12:56 PM
  4. Changing a date to the current year
    By fdnyfish in forum Access
    Replies: 1
    Last Post: 03-01-2008, 08:34 AM
  5. Access Date/Time....I need a "generic" date.
    By beastmaster in forum Access
    Replies: 2
    Last Post: 12-29-2005, 12:55 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