Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 02-07-2010, 06:22 PM
cwwaicw311 cwwaicw311 is offline Windows XP Access 2003 (version 11.0)
Advanced Beginner
 
Join Date: Feb 2010
Posts: 75
cwwaicw311 is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 02-08-2010, 04:25 AM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

The Now() Function returns the current Date and Time.
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
  #3  
Old 02-08-2010, 05:17 PM
cwwaicw311 cwwaicw311 is offline Windows XP Access 2003 (version 11.0)
Advanced Beginner
 
Join Date: Feb 2010
Posts: 75
cwwaicw311 is on a distinguished road
Default

thank... but how do i implement this function into the vb script page in the access form...??
Reply With Quote
  #4  
Old 02-08-2010, 11:50 PM
maximus's Avatar
maximus maximus is offline Windows XP Access 2003 (version 11.0)
Wizard
 
Join Date: Aug 2009
Location: India
Posts: 802
Blog Entries: 1
maximus is on a distinguished road
Default

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.
Reply With Quote
  #5  
Old 02-09-2010, 04:44 AM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

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
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
  #6  
Old 02-09-2010, 07:08 PM
maximus's Avatar
maximus maximus is offline Windows XP Access 2003 (version 11.0)
Wizard
 
Join Date: Aug 2009
Location: India
Posts: 802
Blog Entries: 1
maximus is on a distinguished road
Default

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.
Reply With Quote
  #7  
Old 02-10-2010, 06:53 PM
maximus's Avatar
maximus maximus is offline Windows 7 Access 2010 (version 14.0)
Wizard
 
Join Date: Aug 2009
Location: India
Posts: 802
Blog Entries: 1
maximus is on a distinguished road
Default

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.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Current Date Error McFly Database Design 4 02-04-2010 06:08 AM
Showing date and time when importing to access timpepu Import/Export Data 0 05-07-2009 05:13 AM
Access Runtime 2007 Date Time Picker Vista not working sailinxtc Programming 0 09-17-2008 10:56 AM
Changing a date to the current year fdnyfish Access 1 03-01-2008 05:34 AM
Access Date/Time....I need a "generic" date. beastmaster Access 2 12-29-2005 09:55 AM


All times are GMT -8. The time now is 02:39 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.