A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Date stamp a notes field



 
 
Thread Tools Display Modes
  #11  
Old November 24th, 2006, 10:59 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Date stamp a notes field

What about

Me.Notes = Now() & " " & Me.Notes

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"arogers via AccessMonster.com" u29179@uwe wrote in message
news:69c879e4291ca@uwe...
Hi Tank

Tried it again as you suggest, with and without the underscore. Still
comes
up with a sintax error. The nearest i have got is with:

Private Sub Notes_AfterUpdate()
Me.Notes = Me.Notes & " " & Now() & " "

End Sub

It stamps the notes with date and time but they are always at the latest
note
is always at the bottom and not at the top.

Regards

Allan

Tank wrote:
Hi Allan,

I'm sorry for the confusion. The first two lines are really supposed to
be
on the same line. When I added the code in my reply to you, the posting
pushed a portion of the line onto a second line.

Would you mind moving the second line to the end of the first line? I
think
that will correct your problem.

If I had realized the posting might split the code, I would have
introduced
the underscore to make the split. Properly splitting the line helps the
reader see the entire code without having to scroll left and right to view
the entire line.

The underscore is sometimes referred to as a "Visual Basic
line-continuation
character". As you probably know, anytime you want to continue a line of
code on a second line, you can type a space followed by this character
(the
underscore), and then continue on a new line. Visual Basic interprets the
code as if it were all on one line.

Here's perhaps how I should have displayed the event procedure in your
example (Note the space after & followed by the underscore):

Private Sub CommentUnbound_AfterUpdate()

Me.Notes = vbNewLine & vbNewLine & Format(Now(), "d-mmm-yy hh:nn ") & _
Me.CommentUnbound &" "& Me.Notes

Me.CommentUnbound = Null

DoCmd.GotoControl "CommentUnbound"

End Sub

So, you have two alternatives: (1) Put both lines on one line; or (2) Use
the Space/Underscore to break the code onto two lines.

Please let me know if this helps solve your problem.
-----
Tank

----------------------------------------------

Tank, followed your instructions and all I got was a syntax error with
the
Private sub highlighted and the first two lines of the code in red!

Allan


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200611/1



  #12  
Old November 25th, 2006, 01:16 AM posted to microsoft.public.access.forms
arogers via AccessMonster.com
external usenet poster
 
Posts: 12
Default Date stamp a notes field

Private Sub Notes_AfterUpdate()
Me.Notes = Me.Notes & " " & Now() & " "

End Sub

The above works just fine, except it doesn't put the last notes at the top of
the field, which is were I want it.

Thanks

Allan

Douglas J. Steele wrote:
What about

Me.Notes = Now() & " " & Me.Notes

Hi Tank

[quoted text clipped - 68 lines]

Allan


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200611/1

  #13  
Old November 25th, 2006, 01:48 AM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Date stamp a notes field

Various people in this thread have asked you to explain exactly what it is
you want, and you haven't bothered to answer any of them.

If you can't provide basic information about what it is you're trying to do,
it's extremely difficult for any of us to help!

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"arogers via AccessMonster.com" u29179@uwe wrote in message
news:69ca124f931f7@uwe...
Private Sub Notes_AfterUpdate()
Me.Notes = Me.Notes & " " & Now() & " "

End Sub

The above works just fine, except it doesn't put the last notes at the top
of
the field, which is were I want it.

Thanks

Allan

Douglas J. Steele wrote:
What about

Me.Notes = Now() & " " & Me.Notes

Hi Tank

[quoted text clipped - 68 lines]

Allan


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200611/1



  #14  
Old November 25th, 2006, 11:14 PM posted to microsoft.public.access.forms
arogers via AccessMonster.com
external usenet poster
 
Posts: 12
Default Date stamp a notes field

I'm sorry Douglas I have explained exactly what I would like to do right from
the very start and I will repeat :
( arogers - 11-17-2006 21:22 )

How can I add a current Date/Time stamp to my Notes field (Memo) each time I
add data to the field and ensure the most recent Date/Time is always at the
top of the field. (Access 97) ) I dont think it could be any more basic than
that! and I think you will see from the threads that I have (Bothered) to
answer various people who have tried to help and I appreciate all the help
and advice given so far.

Allan

Douglas J. Steele wrote:
Various people in this thread have asked you to explain exactly what it is
you want, and you haven't bothered to answer any of them.

If you can't provide basic information about what it is you're trying to do,
it's extremely difficult for any of us to help!

Private Sub Notes_AfterUpdate()
Me.Notes = Me.Notes & " " & Now() & " "

[quoted text clipped - 18 lines]

Allan


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200611/1

  #15  
Old November 26th, 2006, 02:14 AM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Date stamp a notes field

Me.Notes = Now() & " " & Me.Notes

will put the current date/time stamp at the beginning of your notes field.

However, from what you're saying, that's not what you want.

I think Tank probably came closest to what you want with the suggestion of
having two text box: one unbound, and one bound to your Notes field.
Whenever you type something into the unbound text box and then move to
another text box, the code Tank gave you will put the current date/time and
whatever you typed into the unbound text box at the top of the bound text
box. There are some potential errors in that code, but since you didn't
indicate what line generates the syntax error, we can only guess. I wouldn't
bother with the DoCmd.GoToControl instruction, and I'd use vbCrLf rather
than vbNewLine. I'd also put a new line between the comment you just added
and the rest of the text in Notes.

Private Sub CommentUnbound_AfterUpdate()

Me.Notes = Format(Now(), "d-mmm-yy hh:nn ") & _
Me.CommentUnbound &vbCrLf & Me.Notes

Me.CommentUnbound = vbNullString

End Sub


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"arogers via AccessMonster.com" u29179@uwe wrote in message
news:69d5935529f8b@uwe...
I'm sorry Douglas I have explained exactly what I would like to do right
from
the very start and I will repeat :
( arogers - 11-17-2006 21:22 )

How can I add a current Date/Time stamp to my Notes field (Memo) each time
I
add data to the field and ensure the most recent Date/Time is always at
the
top of the field. (Access 97) ) I dont think it could be any more basic
than
that! and I think you will see from the threads that I have (Bothered) to
answer various people who have tried to help and I appreciate all the help
and advice given so far.

Allan

Douglas J. Steele wrote:
Various people in this thread have asked you to explain exactly what it is
you want, and you haven't bothered to answer any of them.

If you can't provide basic information about what it is you're trying to
do,
it's extremely difficult for any of us to help!

Private Sub Notes_AfterUpdate()
Me.Notes = Me.Notes & " " & Now() & " "

[quoted text clipped - 18 lines]

Allan


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200611/1



  #16  
Old November 26th, 2006, 02:25 AM posted to microsoft.public.access.forms
John Vinson
external usenet poster
 
Posts: 4,033
Default Date stamp a notes field

On Sat, 25 Nov 2006 22:14:02 GMT, "arogers via AccessMonster.com"
u29179@uwe wrote:

I'm sorry Douglas I have explained exactly what I would like to do right from
the very start and I will repeat :
( arogers - 11-17-2006 21:22 )

How can I add a current Date/Time stamp to my Notes field (Memo) each time I
add data to the field and ensure the most recent Date/Time is always at the
top of the field. (Access 97) ) I dont think it could be any more basic than
that! and I think you will see from the threads that I have (Bothered) to
answer various people who have tried to help and I appreciate all the help
and advice given so far.


Have you *intentionally rejected* the normalized solution, using a
Notes table related one to many to this table? This could have a
date/time field defaulting to Now(), a foreign key to your main table,
and a Text or Memo field for the note; you could display it in reverse
chronological order in a subform/subreport; you could much more easily
search for a note based on a date/time range or vice versa. Having all
of the notes and dates jammed together in a single memo field makes it
much harder to search, especially if you want to associate a note with
its date!

If you REALLY want it this way anyhow, you'll need to update the field
in VBA code; e.g. have two textboxes, txtMemo bound to the memo field
and txtNewNote, unbound. In your code you could use

Private Sub txtNewNote_AfterUpdate()
Dim strNew As String
strNew = GetUserID & " - " & Format(Now, "mm-dd-yyyy hh:nn") & vbCrLf
strNew = strNew & Me!txtNewNote & vbCrLf
strNew = strNew & Me!txtMemo

Me!txtMemo = strNew

End Sub

John W. Vinson[MVP]
  #17  
Old November 26th, 2006, 10:45 PM posted to microsoft.public.access.forms
arogers via AccessMonster.com
external usenet poster
 
Posts: 12
Default Date stamp a notes field

Thanks John,

I'll make do with

Private Sub Notes_AfterUpdate()
Me.Notes = Me.Notes & " " & Now() & " "

End Sub

I will only be adding notes to my notes field 3 or 4 times max in my two sub
forms so scrolling wont be a problem. I already have calls log table which
will be be my main notes records also as a sub form.

Many thanks

Allan

John Vinson wrote:
I'm sorry Douglas I have explained exactly what I would like to do right from
the very start and I will repeat :

[quoted text clipped - 6 lines]
answer various people who have tried to help and I appreciate all the help
and advice given so far.


Have you *intentionally rejected* the normalized solution, using a
Notes table related one to many to this table? This could have a
date/time field defaulting to Now(), a foreign key to your main table,
and a Text or Memo field for the note; you could display it in reverse
chronological order in a subform/subreport; you could much more easily
search for a note based on a date/time range or vice versa. Having all
of the notes and dates jammed together in a single memo field makes it
much harder to search, especially if you want to associate a note with
its date!

If you REALLY want it this way anyhow, you'll need to update the field
in VBA code; e.g. have two textboxes, txtMemo bound to the memo field
and txtNewNote, unbound. In your code you could use

Private Sub txtNewNote_AfterUpdate()
Dim strNew As String
strNew = GetUserID & " - " & Format(Now, "mm-dd-yyyy hh:nn") & vbCrLf
strNew = strNew & Me!txtNewNote & vbCrLf
strNew = strNew & Me!txtMemo

Me!txtMemo = strNew

End Sub

John W. Vinson[MVP]


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200611/1

  #18  
Old November 27th, 2006, 01:48 AM posted to microsoft.public.access.forms
Tank
external usenet poster
 
Posts: 45
Default Date stamp a notes field

Hi Allan. Well, we’re really raking this one over. Hope you’ll hang in.
Doug’s comments are great and right on target.

I’m a bit concerned with your original feedback to me that you get a syntax
error with the coding I suggested. I’m still puzzled how you would get that
error message, but that’s hopefully not going to happen any more. I think
possibly you might have tried to enter the event procedure into the Notes
field rather than into the unbound control that Fred and I suggested earlier.
Although my original coding works fine in my applications, I will present a
slight modification below using some of Doug’s suggestions, simply to be
consistent with input.

I feel the application using an unbound control to enter the data for the
memo field is the best way to go vs. expecting users to enter directly into
the memo field control and expect the date and time to display right away for
them. The date and time will display, but only after tabbing out of the
field control (AfterUpdate).

So, here is the modification I am suggesting in using the unbound control in
conjunction with the Notes memo field.

FOLLOWING IS FOR AN UNBOUND CONTROL THAT TRANSFERS DATA ENTRY TO A MEMO
FIELD IN DESCENDING ORDER (most recent at top) ADDING A DATE/TIME STAMP:

Me.Notes = vbCrLf & vbCrLf & Now() & vbCrLf _
& Me.CommentUnbound & " " & Me.Notes

Me.CommentUnbound = vbNullString


THIS PRODUCES THE FOLLOWING FORMATTING USING SAMPLE DATA:

11-26-07 4:23 pm.
Friday is coming after Thursday.

11-26-07 4:22 pm.
Thursday will come next. This memo system uses an unbound control
to enter data. When the cursor leaves the unbound control, the information
is transferred to the Memo.

11-26-07 4:20 pm.
Wednesday will come first.

Doug Steele’s example produces the following sample:

26-Nov-06 18:03 The most recent entry displays on top (descending order).
26-Nov-06 18:02 Let's go one more time to show the descending order.
26-Nov-06 18:01 Now we will try this again
26-Nov-06 18:00 I will test Doug Steele's version.

Doug did suggest, “I'd also put a new line between the comment you just added
and the rest of the text in Notes”. My coding above addresses Doug’s advice
by starting off with two line feeds.

Please also keep in mind that your need to use the same control names in
your coding as the names you give the controls. For example, if you place an
unbound control on your form in design view, you will have to name it and use
that name in your event procedure. I sometimes make that mistake and lose
time figuring out why the procedure is not working correctly.
“CommentUnbound”, for example is just a name I suggested. You may have been
working with another name for that control, such as “Text1027” or something
like that.

Sorry for any confusion, and please let us know if this is working for you,
and if not, please provide as much information as you can, even if it means
listing your steps in building this event procedure. That way, we might
discover something that will save us all a lot of time.

- - - -
Tank


  #19  
Old November 27th, 2006, 07:04 PM posted to microsoft.public.access.forms
Tank
external usenet poster
 
Posts: 45
Default Date stamp a notes field

Hi Allan,

In reference to your earlier comment, “Tried it again as you suggest, with
and without the underscore. Still comes Up with a sintax error. The nearest I
have got is with:

Private Sub Notes_AfterUpdate()
Me.Notes = Me.Notes &” “& Now() & “ “
End Sub

Since your procedure above starts with “Private Sub Notes_AfterUpdate()”, I
am assuming you are abandoning the suggested use of an unbound textbox to
enter data prefaced by a date/time stamp instead of entering the data
directly into the Notes memo field, or are you saying that you just can’t get
the unbound textbox to work?

Also, are you saying that you cannot get the vbNewLine expression (or
vbCrLf, as offered by Doug) to work?

I’m wondering if your syntax problem stems from possibly these expressions
not being recognized in your Access 97 version. I do recall in years past
that vbNewLine sometimes did not work for me, so I replaced it with chr(13) &
chr(10).

There are at least three choices:

vbNewline
vbCrLf
chr(13) & chr(10)

In my earlier comments to you (11-19-06) I advised, “If vbNewLine does not
work in an application using an earlier version of Access, you might try its
equivalent, chr(13) & chr(10), which is similar to the typewriter’s carriage
return, line feed”.

I’m wondering if you had a chance to test these line feed choices to see if
one of them created the syntax error.
You might try the following:

SUBSTITUTING chr(13) & chr(10) for either vbNEWLINE or vbCRLF:

USING AN UNBOUND TEXTBOX WITH MEMO FIELD

Me.Notes = chr(13) & chr(10) & chr(13) & chr(10) & Now() & chr(13) & chr(10) _
& Me.CommentUnbound & “ “& Me.Notes
Me.CommentUnbound = vbNullString (or simply, Me.CommentUnbound = Null)


USING ONLY A MEMO FIELD FOR DIRECT DATA ENTRY

Me![Notes] = chr(13) & chr(10) & chr(13) & chr(10) & Now() _
& chr(13) & chr(10) & Me![Notes]

Another aspect to your inability to get the procedures to work may be your
form environment, as you commented recently that you are using subforms.
Although I wouldn’t think so, it’s possible your set of mainform/subforms has
methods of operation that no one can analyze via the recent Access Discussion
Group Support postings in your behalf. Perhaps on site person-to-person
guidance may be a better solution.
-----
Tank
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:56 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.