Solved

Append Text to a Memo Field with or without Existing Data

Posted on 2006-11-12
3
1,089 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

830 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