473,396 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Need to remove point form "-" in a memo field

112 100+
I have a memo field that is supposed to be in paragraph format (with no returns) but half of the records are set up as point form with multiple returns. I have figured out how to remove the returns using an update query with:
Expand|Select|Wrap|Line Numbers
  1. Replace([Description],Chr(13) & Chr(10)," ")
However, I need to remove the “-“ that they used in front of each point first, example:
- This is a problem
- This is a problem
- This is a problem
- And so on…
However this is further complicated by the fact that some of the information in the field has “-“ that I don’t want to remove, for example:
Words that have "-" in them like “on-line” and “e-mail” or number with "-" 1-800-297-8511.
I have been trying to use something like:
Expand|Select|Wrap|Line Numbers
  1. IIF([Description] Like "-*", Replace([Description],"-",""), [Description])
but it replaces all the “-“ not just the ones at the front. Also, there are some that start out without a “-“ on the first line and them have point form below which it completely ignores, example:
This is a problem
- This is a problem
- This is a problem
- This is a problem
- And so on…
So I think that I need at code that will replace “-“ if it is the first character or it is after a return, but I can’t figure out how to do that. Then run my remove returns code from above. Can anyone help?
Feb 28 '11 #1
7 1938
orangeCat
83 64KB
If the string to be removed is always " - "
space + dash + space
then use something like

Replace (Description," - "," ")

You would have to repeat this replace until no more
" - " strings exist.
This will not affect "1-800..." or "on-line" etc

**I'd be cautious depending on a memo field to be proper paragraph structure.

You may want to create a function to reformat a memo field whenever it is updated.
Feb 28 '11 #2
Redbeard
112 100+
That will not work because there are sentences like “Object is – 23cm wide” and the code would replace that “-“because it has a space on either side. Also, most of the point form records are actually “-This is a problem” with no space, but some are “- This is a problem” with one space. This is why I need to have a code that eliminates only if it is the first character or after a return. Sorry if the first posts was confusing, the data in this memo field follows no specific format.
Feb 28 '11 #3
orangeCat
83 64KB
Well, that is why I said if the string to be replaced is
always " - ".

The only other advice/approach I can think of is Regular expressions.
You may want to Google that for some explanation and samples.

This could be set up in Access using vba and setting a reference to the appropriate library.

Good luck
Feb 28 '11 #4
gershwyn
122 100+
I threw together a quick VBA function that should accomplish what you want. This would need to be done before removing the returns (or you could make that part of the function, after the rest has been executed.)

Basically all you have to do is loop through, searching for the first hyphen after each return that is found. It then checks to make sure there are no non-space characters between them, so hyphens in phone numbers or compound words will be left alone.

Expand|Select|Wrap|Line Numbers
  1. Public Function DePoint(MemoText)
  2.   'Look for first hyphen in the source text, and remove if it is the first non-space character
  3.   x = InStr(MemoText, "-")
  4.   If Trim(Left(MemoText, x - 1)) = "" Then
  5.     MemoText = Replace(MemoText, "-", "", 1, 1)
  6.   End If
  7.  
  8.   'Check remaining lines
  9.   startPos = 1
  10.   Do
  11.     x = InStr(startPos, MemoText, Chr(13))
  12.     If x = 0 Then
  13.       'end of string reached
  14.       Exit Do
  15.     Else
  16.       'skip over carriage return & line feed characters
  17.       x = x + 2
  18.     End If
  19.  
  20.     y = InStr(x, MemoText, "-")
  21.     If Trim(Mid(MemoText, x, y - x)) = "" Then
  22.       MemoText = Left(MemoText, y - 1) & Right(MemoText, Len(MemoText) - y)
  23.     End If
  24.  
  25.     startPos = x
  26.   Loop
  27.   DePoint = MemoText
  28. End Function
Test input:
Expand|Select|Wrap|Line Numbers
  1. -This is a problem
  2. - This is a problem
  3.  -This is a problem
  4.  - Call me at 555-123-4567
  5. -In-line hyphens are left alone
Output:
Expand|Select|Wrap|Line Numbers
  1. This is a problem
  2.  This is a problem
  3.  This is a problem
  4.   Call me at 555-123-4567
  5. In-line hyphens are left alone
Mar 1 '11 #5
Redbeard
112 100+
Hi gershwyn this code looks great but I am not sure how to run it in my update query? I put it into a module but don't know how to run a module off an update query? How do I enter it into design view so that it will run? I have never used modules before. Or am I doing this wrong?
Mar 1 '11 #6
Redbeard
112 100+
If anyone can answer the previous post about how I would use the above code I would still like an answer to that. However, I have been able to figure out how to do this without using the code above, it is not as clean but still works. I run a series of update queries on my field to get the same results. See below:
Run these one at a time on your field in an update query.
Starts with:
- This is a problem
-This is a problem
-This is a problem
-519-765-3212
In-Line Hyphens

Removes “-“ if at start of field and Trims any spaces

Update to:
Expand|Select|Wrap|Line Numbers
  1. Trim(Replace([MyFeild],"-","",1,1))
Criteria:
Expand|Select|Wrap|Line Numbers
  1. Like “-*”
This is a problem
-This is a problem
- This is a problem.
-519-765-3212.
In-Line Hyphens

Removes case returns and line feeds and replaces them with “@” (@ is a character that I do not have in that field)

Update to:
Expand|Select|Wrap|Line Numbers
  1. Replace([MyFeild],Chr(13) & Chr(10),"@")
This is a problem@-This is a problem@- This is a problem.@-519-765-3212.@In-Line Hyphens

Removes “@-“ and replaces with “. “

Update to:
Expand|Select|Wrap|Line Numbers
  1. Replace([MyFeild],"@-",". ")
This is a problem. This is a problem. This is a problem.. 519-765-3212.@In-Line Hyphens


Removes “@“ and replaces with “ “

Update to:
Expand|Select|Wrap|Line Numbers
  1. Replace([MyFeild],"@",". ")
This is a problem. This is a problem. This is a problem.. 519-765-3212.. In-Line Hyphens

Removes spaces before a period if there is any
Update to:
Expand|Select|Wrap|Line Numbers
  1. Replace([MyFeild]," .",".")
This is a problem. This is a problem. This is a problem.. 519-765-3212.. In-Line Hyphens

Removes double period
Update to:
Expand|Select|Wrap|Line Numbers
  1. Replace([MyFeild],".. ",". ")
This is a problem. This is a problem. This is a problem. 519-765-3212. In-Line Hyphens


Removes double spaces, may have to be run multiple times!
Update to:
Expand|Select|Wrap|Line Numbers
  1. Replace([MyFeild],"  "," ")
This is a problem. This is a problem. This is a problem. 519-765-3212. In-Line Hyphens

It works but a lot of updateing. However it only has to be done once!
Thanks
Mar 2 '11 #7
gershwyn
122 100+
Once you've put the code into your module, you would call it just like any other function. In your original post, you said you had an update query using the Replace function. Just change the entry in the Update To field (in query design view) to:
Expand|Select|Wrap|Line Numbers
  1. Depoint([Description])
Mar 2 '11 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: u7djo | last post by:
Hi, I'm currently building an application in Access and as part of this need to import forms and modules from another database. Some of the imports will be revisions of existing forms/modules so I...
7
by: alsemgeest | last post by:
Hi, I'd like to change the properties of the default form design. Every form I need to change many settings. Especially the following properties (I try to translate them well from Dutch): * make...
1
by: skootr | last post by:
Has anyone seen any COMPLETE bound form examples? By complete, I mean a form that has Add/Edit/Delete capabilities. Every example I've seen on the 'net, in books, and in the VB.Net Resource Kit...
5
by: Scott H | last post by:
Hi All, Coming from VB6, there was a bit of a difference in the way you display a form, I Thought I'd nailed instanciating a form, but I'm quite stuck with something that doesn't make sense. ...
7
by: Progalex | last post by:
Hi everybody! I have a listview and a treeview in a form . With an OpenDialog I let the user select multiple files and then these files are added to the listview with the complete pathname,...
3
by: aprivate | last post by:
Hi I am having some problem with a form timer. I added a progress bar to increment its value and the timer works when I use form1.showdialog() However when I use form1.show, form1.refresh()...
1
by: dman | last post by:
Hi, I am a total newbie to asp.net. I have spent the last week or so trying to find a good tutorial that would show me how to create a form that would be entered into a SQL database and then...
4
by: Martijn Mulder | last post by:
I have a menu option 'Open...' that opens an OpenFileDialog to select an image file to open. Than I need to call Form.Invalidate() to clear the Form and display the image. This happens in a...
1
by: TopherB | last post by:
Hi, First let me say that my knowledge of HTML and Javascript is fairly limited. But I am stuck in a situation of trying to adapt a website's shopping cart to a new one. Here's the problem, the...
0
by: azsxsza | last post by:
For my program I need the form to be 0% visible and I need for the controls on the form to be 100% visible. At first the TransparencyKey property worked for me but then I started drawing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.