Auto populate static date/time (1 Viewer)

Patm

New member
Local time
Today, 16:47
Joined
Oct 10, 2001
Messages
7
I am developing a db for a phone log in regards to technical inquiries. The first control on the form is a combo box with a drop down for particular individuals. The next 2 controls are date and time text boxes. They both have their appropriate control sources of date and time.
What I would like to be able to do is have the date and time fields auto-populate with the current d&t as soon as the combo box is populated. I want these to be static, and to not update if someone goes back to that record.
Thanks for the help.
 

R. Hicks

AWF VIP
Local time
Today, 10:47
Joined
Dec 23, 1999
Messages
619
Set the Enabled property of both textboxes (txtDate and txtTime) to "No". Also set the Locked property of both to "Yes". This will keep the user from altering the entries.

Now use the After Update event of the combobox to populate the 2 txtboxes if it is a "New Record".

Private Sub YourComboName_AfterUpdate()
If Me.NewRecord And IsNull(Me.YourDateTxtbox) And IsNull(Me.YourTimeTxtbox) Then
  Me.YourDateTxtbox = Date()
  Me.YourTimeTxtbox = Time()
End If
End Sub

(change the names of the controls above to the names of your controls)

HTH
RDH

[This message has been edited by R. Hicks (edited 10-25-2001).]
 

Patm

New member
Local time
Today, 16:47
Joined
Oct 10, 2001
Messages
7
Very helpful!
One question. When I go into After Update event it brings up the dialogue box for the Expression, etc. Builder. Do I select Expression? Or am I entering the Private Sub... lines in somewhere else?
Pat
 

jai kushwaha

Registered User.
Local time
Today, 21:17
Joined
Nov 1, 2015
Messages
61
i want to do same thing on got Focus "txtTime" can you tell me how to do it???
 

Grumm

Registered User.
Local time
Today, 17:47
Joined
Oct 9, 2015
Messages
395
From what i can see, the previous post (14 years ago omg...) said to disable the txtDate and txtTime.
This means that they cannot get the focus ever. So adding code on the Focus will never work.
 

Minty

AWF VIP
Local time
Today, 16:47
Joined
Jul 26, 2013
Messages
10,374
Holy Thread Resurrection Batman!!
 

Users who are viewing this thread

Top Bottom