I have a memo field (in Access 2K) that I use to hold text versions of
emails. Here is an example:
---
From: Mickey Mouse
To: Minnie Mouse
Date: 7/21/04 1:10PM
Subject: Fwd: Topics for conference call
Thanks. That was the premise of Goofy's call earlier today.
---
I want to parse out the header data to respective fields (To, From,
Date, Subj). I've been all over the posts on this newsgroup today.
This is my first real "parse experience". Here's what I have so far
(this is to get the "To" name):
Dim fldMsg As String
Dim ToName As String
fldMsg = [Forms]![MESSAGES_ENTRY]![MESSAGE]
ToName = (Mid(fldMsg, ((InStr(1, fldMsg, "To:", 0)) + 4), _
(InStr((InStr(1, fldMsg, "To:", 0)), fldMsg, Chr(13),
vbBinaryCompare))))
MsgBox (ToName)
Now that you're done laughing at my code (just kidding), the only
purpose of the msgbox at this point is to show me what I have when I
run it. (For some reason whenever I try to run it from the code
window, it opens a Run Macro box with nothing in it. I have to
actually run this from the form) Ultimately, I would like to paste
the retrieved data into fields corresponding w/this message.
What I get when I run this is:
Minnie Mouse
Date: 7/21/04 1:10PM
It doesn't stop at the carriage return after "Mouse"...I've tried
various combinations of start positions (I even tried "1") and all it
ever does is change the position on the "Date" line where it stops
collecting the data...it never stops after "Mouse".
ANY help would be appreciated. Thanks!!! 2 3059 ds********@yahoo.com (Donna Sabol) wrote in message news:<e8**************************@posting.google. com>... I have a memo field (in Access 2K) that I use to hold text versions of emails. Here is an example:
--- From: Mickey Mouse To: Minnie Mouse Date: 7/21/04 1:10PM Subject: Fwd: Topics for conference call
Thanks. That was the premise of Goofy's call earlier today. ---
I want to parse out the header data to respective fields (To, From, Date, Subj). I've been all over the posts on this newsgroup today. This is my first real "parse experience". Here's what I have so far (this is to get the "To" name):
Dim fldMsg As String Dim ToName As String fldMsg = [Forms]![MESSAGES_ENTRY]![MESSAGE]
ToName = (Mid(fldMsg, ((InStr(1, fldMsg, "To:", 0)) + 4), _ (InStr((InStr(1, fldMsg, "To:", 0)), fldMsg, Chr(13), vbBinaryCompare)))) MsgBox (ToName)
Now that you're done laughing at my code (just kidding), the only purpose of the msgbox at this point is to show me what I have when I run it. (For some reason whenever I try to run it from the code window, it opens a Run Macro box with nothing in it. I have to actually run this from the form) Ultimately, I would like to paste the retrieved data into fields corresponding w/this message.
What I get when I run this is:
Minnie Mouse Date: 7/21/04 1:10PM
It doesn't stop at the carriage return after "Mouse"...I've tried various combinations of start positions (I even tried "1") and all it ever does is change the position on the "Date" line where it stops collecting the data...it never stops after "Mouse".
ANY help would be appreciated. Thanks!!!
Your memo looks like:
xxx<CR>
To: yyyy yyyy<CR>
You're looking for Mid(fldMsg, InStr(1,fldMsg, "To:",0))+4,
lengthofyyyys))
lengthofyyyys = PositionofCR - PositionofToPlus4 (you missed this
last term)
PositionofCR = InStr(InStr(1,fldMsg,"To:",0), fldMsg, Chr(13),
vbBinaryCompare)
PositionofToPlus4 = InStr(1,fldMsg,"To:",0) + 4)
So your final string becomes something like:
Mid(fldMsg, InStr(1,fldMsg, "To:",0))+4,
InStr(InStr(1,fldMsg,"To:",0), fldMsg, Chr(13), vbBinaryCompare) -
InStr(1,fldMsg,"To:",0) + 4)))
This should get you close enough to zero in on the problem.
James A. Fortune
Just an update....
It doesn't show in this newsgroup but I did receive a reply to this
message through DevelopersDex (thank you, by the way, to the person
who responded).
As usually happens for me, once I ask the question, my brain gets
offended and starts coming up with the answer on its own, rather than
waiting for someone to help. Here is what I came up with, and it's
working just fine. I thought I would post this for anyone who
searches for this kind of thing in the future:
Dim fldMsg As String
Dim FromStart As Integer
Dim ToStart As Integer
Dim DateStart As Integer
Dim SubjStart As Integer
Dim fldTO As String
Dim fldFROM As String
Dim fldDATE As Date
Dim fldSUBJECT As String
fldMsg = [Forms]![MESSAGES_ENTRY]![MESSAGE]
FromStart = (InStr(1, fldMsg, "From:", 0)) 'THE "START" LINES FIND
STARTING
ToStart = (InStr(1, fldMsg, "To:", 0)) 'POSITION FOR EACH PIECE OF
DATA
DateStart = (InStr(1, fldMsg, "Date:", 0))
SubjStart = (InStr(1, fldMsg, "Subject:", 0))
'THESE "ME!" LINES APPEND THIS DATA INTO THE APPROPRIATE FIELDS
Me!fldFROM = (Mid(fldMsg, (FromStart + 7), (ToStart - (FromStart +
7))))
Me!fldTO = (Mid(fldMsg, (ToStart + 4), (DateStart - (ToStart + 4))))
Me!fldDATE = (Mid(fldMsg, (DateStart + 7), (SubjStart - (DateStart +
7))))
Me!fldSUBJECT = (Mid(fldMsg, (SubjStart + 10), _
((InStr(SubjStart, fldMsg, Chr(13), 0)) - (SubjStart +
10))))
The problem I was having before (where it was passing the stop
position I was setting) was because MID needs the start position and
HOW MANY CHARACTERS AFTER. I was telling it the start position and
STOP POSITION. What I did above was find the difference between the
start & stop positions to give the number of characters.
Thanks everyone! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Alfredo Agosti |
last post by:
Hi folks,
I have an Access 2000 db with a memo field.
Into the memo field I put text with bold attributes, URL etc etc
What I need to to is converting the rich text contained into the memo...
|
by: Shyguy |
last post by:
I want to create two buttons on a form. One would allow the user to
Copy the contents of the current records memo field, the other would
allow them to print. I set up a report based on the memo...
|
by: PMB |
last post by:
Thank you in advance for any and all assistance.
I'm trying to input data from strings to a memo field. I would like to know
how to check first to see if there is text there currently and if so...
|
by: MLH |
last post by:
I have a form with two controls:
!! - combo box
!! - text box
A button on the form tries to run this SQL when clicked...
INSERT INTO BodyMsgsSent (ToWhom, BodyText)
SELECT DISTINCTROW !! AS...
|
by: Ennio-Sr |
last post by:
Hi all!
After a very long struggle I finally succeded in transferring my old
*.dbf file and the relating *.dbt (alias memo fields) to a pg table.
For the time being I put the memo field in a...
|
by: alexsg |
last post by:
A little while ago Ron P kindly responded to my inquiry on how to copy
the first line of memo field into a text field, using a query:
left(,instr(1,,vbCrLf)-1)
This is great, but I would like...
|
by: Roger |
last post by:
I've got two tables in sql2005 which have an 'ntext' field
when I linked the first table in access97 last week using an odbc data
source the access-field type was 'memo'
when I link the 2nd...
|
by: barbara_dave |
last post by:
Hi all,
I want to change a field data type from Text to Memo.The reason is I
need to type more text in that field.
when I was saving the change I got error message "The width of a
Unicode...
|
by: tfurubay |
last post by:
Hi,
I am developing a DB that imports a CSV file from a commerce site. The file is a CSV file with double quotes to identify text. In this file, there is a memo field where people occassionally...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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: 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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |