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: - 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 dont 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: - 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 cant figure out how to do that. Then run my remove returns code from above. Can anyone help?
7 1938
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.
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.
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
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. - Public Function DePoint(MemoText)
-
'Look for first hyphen in the source text, and remove if it is the first non-space character
-
x = InStr(MemoText, "-")
-
If Trim(Left(MemoText, x - 1)) = "" Then
-
MemoText = Replace(MemoText, "-", "", 1, 1)
-
End If
-
-
'Check remaining lines
-
startPos = 1
-
Do
-
x = InStr(startPos, MemoText, Chr(13))
-
If x = 0 Then
-
'end of string reached
-
Exit Do
-
Else
-
'skip over carriage return & line feed characters
-
x = x + 2
-
End If
-
-
y = InStr(x, MemoText, "-")
-
If Trim(Mid(MemoText, x, y - x)) = "" Then
-
MemoText = Left(MemoText, y - 1) & Right(MemoText, Len(MemoText) - y)
-
End If
-
-
startPos = x
-
Loop
-
DePoint = MemoText
-
End Function
Test input: - -This is a problem
-
- This is a problem
-
-This is a problem
-
- Call me at 555-123-4567
-
-In-line hyphens are left alone
Output: - This is a problem
-
This is a problem
-
This is a problem
-
Call me at 555-123-4567
-
In-line hyphens are left alone
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?
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: - Trim(Replace([MyFeild],"-","",1,1))
Criteria:
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: - 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: - 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: - 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: - 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: - 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: - 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
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: Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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.
...
|
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,...
|
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()...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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...
| |