Full Version: Date and time in text box
UtterAccess Forums > Microsoft® Access > Access Date + Time
I have one question and the problem at the same time:)! How i could create a function or what kind of code do i need so that whenever i would press on key on a keyboard the new date and time would be automaticly written in text box. Why? I have a text box and i am writting some informations about company, whenever i have meeting with thme. So tha i wouldnt have to write a date and time in a tex box before a note that i will make i would like that access woudl put a date ther. For example.
02/05/2005 Note: Company A needs an new contract
05/07/2005 Note: ....
If the key would be a date or eaven better whenever i would statr writing in to text box( every new day ) a date of this day would be written down!
Thank you,
Larry Larsen
Hi K
Just a quick question regarding the date that's entered, would the date value be the current date or another date..?
I'm thinkig of applying a default value at table level or using the "On Change" event to trigger the date input.
Hi Larry
The value would be current date.
Larry Larsen
Just set default at form level to apply the current date to the control..
Default > =Date()
Date() will show 20/11/2005
Now() will show both date & time 20/11/2005 13:21:44
Yes but the problem is that we are tallking about one text box that is being updatet every few days. This is a memo field in a table. This is an text box where i write something new about the customer and what i would like to do i that every time i would go on ( every new day ) with the text in that text box, there would be created a date of that day.
Text Box:
21/04/2005 I had a meeting with J.B. 23/04/ 2005 J.B called me to give me catalog ....
If i use a default value , the date will appeare only at first input. What i would like to do is that every time i write something new into text box there is an entry with date of a day , and after that a new note is written.
just an idea...
ather than type directly into the text box, use a button and the Inputbox$ function to get the input...
Add the following function to a code module
Function GetLogText(ct As Control) As String
Dim strText As String

strText = InputBox$("Enter text")

If Len(strText) > 0 Then
strText = Now & " " & strText & Nz(ct, "")
End If

GetLogText = strText

End Function
in the Forms button events: ButtonName_Click event...
txtLog = GetLogText(txtLog)
Assuming that txtLog is the name of the text box you store your log in. Lock the textbox so you gain back the control...
If you need a larger input area that the InputBox function provides, you can create your own that allows more customization.
You could type your notes in your textbox, then click a button that would create a string to enter into the memo field. The string would use =Date() for the first part then an & with [form]![textbox].
Sorry I don't know the proper syntax off the top of my head as this is all new to me.
The easier thing to do would be to create another field for the entry date and use the method that Larry suggests above. then whenever you have a report or are viewing the notes, display the date field with it. In your form, you can place a textbox just before the notes box and set it to the date field to view the date of the record there.
Why are you using a memo field in the same record? Why aren't you using a child table? You should have a child table:
CustInfoID (PK Autonumber)
CustomerID (FK)
If you need to Info can be a memo field. InfoDate would default to Now().
You would use a subform on your main Customer form to add Info items
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.