Solved

Append Text to a Memo Field with or without Existing Data

Posted on 2006-11-12
3
1,085 Views
Last Modified: 2008-01-09
I have a Memo field on a form. The memo field may or may not have data typed in it.

When I reschedule a job (using a form), I would like to have the memo field populated with some data

for example - if the memo field had nothing in it, I want it to read

11/12/2006 - rescheduled from 11/12/06 to 11/15/06 -  by Joe

I will use something like the code below to build the string to insert.....

me.memo = Now() & " - rescheduled from " & [previousdate] & " to "& [newdate] & " - by "& [username]

I am not too worried about the building string


but if the memo field already had data in it, I want the data that is there to remain, then add text below it - like this...


Keys are in mailbox. (existing data)
space
11/12/2006 - rescheduled from 11/12/06to 11/15/06


I am not sure which way I want to do it - so 2 examples are below.....


either like this - no space after existing text(new line right below existing data)

Keys are in mailbox.
11/12/2006 - rescheduled from 11/12/06to 11/15/06

... or maybe like this - a space below existing data

Keys are in mailbox.
 
11/12/2006 - rescheduled from 11/12/06to 11/15/06


I know I need to use something like   vbcrlf  for the space, but how do I add the data after whatever may already be entered in the memo field?


Thanks -AB











0
Comment
Question by:abinboston
  • 2
3 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 250 total points
ID: 17928323
Try:

if len(me.memo) > 0 then
   me.memo = me.memo & cbCRLF &  cbCRLF & Now() & " - rescheduled from " & [previousdate] & " to "& [newdate] & " - by "& [username]
else
   me.memo = Now() & " - rescheduled from " & [previousdate] & " to "& [newdate] & " - by "& [username]
endif

Getting the idea ?

Nic;o)
0
 
LVL 35

Assisted Solution

by:Raynard7
Raynard7 earned 250 total points
ID: 17928487
I agree with nico's approach however I would do it slightly differently, I would also check if It was null - additionally there is a spelling mistake - I'm sure nico meant vbCrLf rather than cbCRLF

if isnull(me.memo) = false and len(me.memo) > 0 then
   me.memo = me.memo & vbCRLF &  vbCRLF & Now() & " - rescheduled from " & [previousdate] & " to "& [newdate] & " - by "& [username]
else
   me.memo = Now() & " - rescheduled from " & [previousdate] & " to "& [newdate] & " - by "& [username]
endif
0
 
LVL 54

Expert Comment

by:nico5038
ID: 17928514
Correct Raynard7, the cb was a typo (mondaymorning fingers, sorry...) and the Null shouldn't interfere, but when you want to check this is the way I generally do it:

if len(Nz(me.memo)) > 0 then
   me.memo = me.memo & vbCRLF  ....etc...

Nic;o)
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now