How do I insert date and time before typing a new note in Access 2

G

Guest

I am putting a database together for my company and everything has gone
smoothly to this point. I have now run into a slight problem. In the form
view I set up a memo box so employees of my company can type notes into the
box when they contact customers. I would like for the date and time to be
stamped on those notes as they are added. For example if I talk to a customer
today and they want the product delivered to their home rather then the
office I want to be able to go to the memo field and type in a note making
all other employees aware of that. Before the note is displayed I would like
the note to display the time and date I typed the note in. How do I
accomplish this?
 
G

Guest

I would put a command button to "create a new note" and have your text box
locked initially.

Then, in the click event of the command button you can put:

Me.YourTextBoxNameHere.Locked = False
Me.YourTextBoxNameHere = Me.YourTextBoxNameHere & vbCrLF & _
Now & ----
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
____________________________________
Access 2000, 2003, 2007, SQL Server 2000, Crystal Reports 10/XI, VB6
WinXP, Vista
 
G

Guest

I would change your table structure so that all notes are stored in a related
table with fields like:

tblCustomerContacts
============================
CustomerContactID autonumber primary key
CustomerID relates to previous notes record table
ContactDateTime
Notes
EmployeeID relates to primary key of employee table

Each addition to the notes would create a new record in this new table. This
solution would provide greater flexibility and when not cause issues when two
employees are editing a customer record.
 
G

Guest

After reviewing the reply to my question I inserted a command button. Then I
went to the on click section of the event and clicked on event procedure
which took me to the visual basic editor. The name of my text box is "Notes"
so I proceded to input the suggested code which looks like this:

Private Sub Command96_Click()
Me.Notes.Locked = False
Me.Notes = Me.Notes & vbCrLF & _
Now & ----
--
End Sub

When I did that I got an error message saying:

Compile error:
Expected: Expression

Anyone have any ideas what I am doing wrong?
 
J

John W. Vinson

I am putting a database together for my company and everything has gone
smoothly to this point. I have now run into a slight problem. In the form
view I set up a memo box so employees of my company can type notes into the
box when they contact customers. I would like for the date and time to be
stamped on those notes as they are added. For example if I talk to a customer
today and they want the product delivered to their home rather then the
office I want to be able to go to the memo field and type in a note making
all other employees aware of that. Before the note is displayed I would like
the note to display the time and date I typed the note in. How do I
accomplish this?

Rather than storing multiple items of data - many notes, each with its own
timestamp - all in one memo field, I'd VERY strongly suggest using a one to
many relationship to a Notes table. This table should have a foreign key field
linked to the primary key of your current table; a date/time field NoteTime
with a default value of Now(); and a memo field in which to enter each note in
a separate record. You could use a continous Subform with just a textbox for
the memo field enabled to enter the notes.

John W. Vinson [MVP]
 
G

Guest

I would agree about the other two responses regarding setting up the notes
field properly.

To answer the question about the expression, you need the ---- in quotes
"----"

It was late last night when I answered and did two things wrong -

1. missed the quotes

2. didn't give the more appropriate answer about designing the database
correctly with the notes table.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
____________________________________
Access 2000, 2003, 2007, SQL Server 2000, Crystal Reports 10/XI, VB6
WinXP, Vista
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top