By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,849 Members | 2,169 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,849 IT Pros & Developers. It's quick & easy.

Time field on Access does not display.

P: 42
The following is the code I am using in an attempt to add a Date and Time stamp to new records saved in main table. The date returns but the Time doesn't. I have tried various fixes like creating a TimerInterval text box with little look.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. 'Form_frm_CLLDateEntry.Filter = "[tbl_CallData].Analyst" = Me.Text25
  3. 'Form_frm_CLLDateEntry.FilterOn = True
  4.  
  5. 'strRacf = "Query_qry_getLoginID.RacfID"
  6. 'Me.Text25.Value = strFacf
  7.  
  8. Me.txtDate = DateValue(Now)
  9. Me.txtTime = TIME()
  10. Me.TimerInterval = 1000
  11.  
  12.  
  13. End Sub
Mar 24 '10 #1

✓ answered by missinglinq

You're using the wrong event and you're not testing to see if it's a new record. This should do it:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.  If Me.NewRecord Then
  3.   Me.txtDate = Date
  4.   Me.txtTime = Time
  5.  End If
  6. End Sub
This will populate your fields when a new record is started. If you want to Time Stamp to reflect when you finish and actually save the record, move the code to the Form_BeforeUpdate event, instead of Form_Current.

Linq ;0)>

Share this Question
Share on Google+
2 Replies


missinglinq
Expert 2.5K+
P: 3,532
You're using the wrong event and you're not testing to see if it's a new record. This should do it:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.  If Me.NewRecord Then
  3.   Me.txtDate = Date
  4.   Me.txtTime = Time
  5.  End If
  6. End Sub
This will populate your fields when a new record is started. If you want to Time Stamp to reflect when you finish and actually save the record, move the code to the Form_BeforeUpdate event, instead of Form_Current.

Linq ;0)>
Mar 24 '10 #2

P: 42
I will try in the morning on my form that is using a Select Query.
Mar 25 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.