I don’t know what event to use. Help please.

RJ45

Registered User.
Local time
Today, 17:00
Joined
Sep 18, 2003
Messages
13
I need that Date and Time to be stored separately, But the problem I have, is I don’t want the user to have any control over the input of the Date and Time.


BUT When the user starts typing in the “notes” field, that I when I want the time and date to be automatically populated.
I've been trying to find example on this topic, but i came up empty. I need help coding this.


Any help will be Appreciated.

thank you.
 

Attachments

To record the time the moment the user starts typing, use the On Key Down event. In order to make sure you're not overwriting the time every time a key is pressed, however, you first need to check to see if this is the first time something was entered. For example:

IF isnull(myTextField) = True THEN
myDateField = Now()
END IF
 
Stuck on this, still wont work for me. help anyone.
 

Attachments

Here's a list of what is wrong:
1. The variable names in your code do not match the control names on your form.
2. You do not have Option Explicit set in your form module so you are not getting any compile errors and you are also not getting any runtime errors because VBA is creating variables for you on the fly.
3. You are using Function names (Date and Time) as your column names.
4. You say you "need" date and time to be separate (you don't and in fact may have trouble working with them if they are separate) but you are attempting to set the value of both fields to Now() which is the function that returns both current date and time.
5. The date and time controls are not locked and so the user can type over them.

Here's another suggestion:
1. Your form is based on a table. It is better to base the form on a query. Decide whether you want to see the notes in ascending or descending order and sort the query accordingly.
2. You probably need more columns in the table such as something like Category or the primary key of some related table so that you can associate the note with something.
 

Users who are viewing this thread

Back
Top Bottom