[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Memo field update

Posted on 2013-01-28
9
Medium Priority
?
577 Views
Last Modified: 2013-01-28
Hi Experts,
I have added a user name and time stamp to a memo field as an "after update" event.  The code works when something is added, but also is fired when something is deleted, which I don't want. Could someone please modify the attached code so that it is only fired when something is added?
Thanks experts!
Private Sub Notes_AfterUpdate()
   
    Me.Notes = Me.Notes & " (added by " & fOSUserName & " on " & Now() & ")" & vbCrLf
    
End Sub

Open in new window

0
Comment
Question by:Harry Batt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 38827243
What you are asking is pretty well impossible unless you are saying that you have specific separate procedures for adding content and deleteing content.

There is no way to tell whether content was changed, added or deleted unless you get involved in some very sophisticated character matching - all you can tell is that something was done to the text.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38827266
what version of access are you using?
0
 
LVL 77

Expert Comment

by:peter57r
ID: 38827302
I suppose that if you did something like...

Me.Notes = Me.Notes & " (added by " & fOSUserName & " on " & Now() & ") ***" & vbCrLf

then you could test for the presence of *** in the last, say, 7 characters and if found , do not append the username and timestamp.
0
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

 

Author Comment

by:Harry Batt
ID: 38827340
I am using Access 2007
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38827402
0
 

Author Comment

by:Harry Batt
ID: 38827583
I find that the ColumnHistory method also appends the code with the user name and date when data is being deleted, so unless I am wrong, I don't believe this is a viable solution. I haven't tried Peter57's character matching solution, but if this is the optimal way of handling this issue, what would the code look like?
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 38827612
can you try using

if len(me.notes).oldvalue > len(me.notes).value  then  'this means that something was deleted
0
 

Author Comment

by:Harry Batt
ID: 38827871
Capricorn1,

With a slight modification, this works.  (The .value expression triggered an error)

Thanks!
Private Sub Notes_AfterUpdate()
    If Len(Me.Notes.OldValue) > Len(Me.Notes) Then 'this means that something was deleted
        Exit Sub
    Else

    Me.Notes = Me.Notes & " (added by " & fOSUserName & " on " & Now() & ")" & vbCrLf
    
    End If
End Sub

Open in new window

0
 

Author Comment

by:Harry Batt
ID: 38828154
One change to correct a bug when deleting:
Private Sub Notes_AfterUpdate()
   
    If Len(Me.Notes.OldValue) > Len(Me.Notes.Value) Then 'this means that something was deleted
    
        Exit Sub
    Else
 If Me.Dirty Then Me.Dirty = False
    Me.Notes = Me.Notes & " (added by " & fOSUserName & " on " & Now() & ")" & vbCrLf
    
    End If
   
End Sub

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question