• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1096
  • Last Modified:

Append Text to a Memo Field with or without Existing Data

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
abinboston
Asked:
abinboston
  • 2
2 Solutions
 
nico5038Commented:
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
 
Raynard7Commented:
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
 
nico5038Commented:
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now