473,385 Members | 1,707 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,385 software developers and data experts.

Data from memo field

171 100+
Hi All
I have a table with one field as memo. This has so many lines of data.
I like to find data from a particular line (say n th line). Pls help with a function which i can use in the query. I have little knowledge about the instr.
But i dont know how to check the line number.
Thank you


Eg:

line1
line2
line3
line4
line5
line6 etc
Feb 10 '08 #1
5 4907
mshmyob
904 Expert 512MB
You could use the instr or instrrev functions.

Memo fields are not really set up as line number but the above functions will allow you to search for a specific string.

But if you put numbers before each line of data you could then use the functions above to find the starting and ending points of each line and then extract the data.

Hi All
I have a table with one field as memo. This has so many lines of data.
I like to find data from a particular line (say n th line). Pls help with a function which i can use in the query. I have little knowledge about the instr.
But i dont know how to check the line number.
Thank you


Eg:

line1
line2
line3
line4
line5
line6 etc
Feb 10 '08 #2
missinglinq
3,532 Expert 2GB
Cardinal Rule of Memo Fields

Thy shall not enter any data that will ever need to be manipulated in any way!

And you've obviously violated this rule! Memo fields are designed to hold memos, i.e. notes, they are not designed simply as a place to cram bunches of data in so that you don't have to move from field-to-field when doing data entry. This is, I expect, going to be a mare's nest to sort out, if it can, in fact, be sorted out!

There's a few things we probably need to know to try to get you out of this:
  1. What kind of data does this field hold, i.e. interview notes, recipes, driving directions?
  2. Exactly how are you defining a "line" here? Do you mean a line as it appears when viewing your form, or have you done something during data entry to create a new line, such as hitting <Enter> or <Ctrl> + <Enter>?
  3. Exactly what is this data you're trying to retrieve? Is there anything uniquely identifiable about the data, especially vis a vis how the line begins? Does it always start with the words "In the beginning" or "It was a dark and rainy night?" Does it always have a date in it, or a Currency mark?
Linq ;0)>
Feb 10 '08 #3
mshmyob
904 Expert 512MB
As a followup here is some code to extract data from line in a memo field.

First in my example I have a memo field that has multiple lines like so

1. This is line 1
2. This is line 2
3. This is line 3

Notice I need some kind of identifier to identify the start of each line. I would recommend you find something very UNIQUE (not what I used)

The code to extract line 1 and 2 is as follow. You can expand on it by using loops, case statements etc.

Expand|Select|Wrap|Line Numbers
  1. ' what line number do you want to search for
  2. vLine = 1
  3. ' get the starting position of the 1st occurance of the value stored in vLine
  4. vStart = InStr(1, txtMemo, vLine)
  5. ' figure out where the next line starts
  6. vEnd = InStr(1, txtMemo, vLine + 1)
  7. 'display the line number on the form
  8. Me.txtLine1 = Mid(txtMemo, vStart + 2, vEnd - vStart)
  9. 'same as above but for line 2    
  10. vLine = 2
  11. vStart = InStr(1, txtMemo, vLine)
  12. vEnd = InStr(1, txtMemo, vLine + 1)
  13. Me.txtLine2 = Mid(txtMemo, vStart + 2, vEnd - vStart)
  14.  
As you can see if searching for say Line 1 if the number 2 appears in line 1 then everything will be messed up. But it gives you an idea of how it can be done.

Hope this helps - please feel free to ask for more clarification.
Feb 10 '08 #4
rajeevs
171 100+
Hi
I like to give more details about my query
The data is actually stored in the memo field of ms access table.
the data will look like below mentioned
always start and end with brackets
The lines starts with -
I want to extract certain data from this field and make it as one record with different fields
like field 1 as ALPHANUMERIC maximum 10 or 12
second field as data from the next line
third field as from next line like that
Hope it is clear pls help
Thanks in advance

(XXX-ALPHANUMERIC maximum 10 or 12/XX
-alphanumeric max 5/X-XXXXXXXX/X
-xxxxxxxx
-alphanumeric any number LIKEXXX 110 XXXDCXXXXXXV
XXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-xxxxxxxx XXXX XXXX
-XXX/XXXXXXXX XXXXXXXX ETC
XXXXXXXXXXXXXXX XXXX
-XXXXXXXXXXXXX
XXXXXXXXX
XXXXXXX)
Feb 13 '08 #5
mshmyob
904 Expert 512MB
Ok here is some sample code to find any line in a memo field regardless of line identifiers. The only requirement is that the end of each line has a CLF. Obviously you would redo this into a LOOP statement.

I tested it with the Memo data you supplied and it works fine. If you need any more clarification please do not hesitate to ask.

Expand|Select|Wrap|Line Numbers
  1. ' get the 1st line
  2. VStart = InStr(1, txtMemo, "(")
  3. ' figure out where the line ends by looking for a CLF
  4. Vend = InStr(1, txtMemo, Chr(10))
  5. 'display the line number on the form
  6. Me.txtLine1 = Mid(txtMemo, VStart, Vend - VStart)
  7.  
  8. ' this is sample to get line 2
  9. VStart = Vend + 1
  10. ' figure out where the line ends by looking for a CLF
  11. Vend = InStr(VStart, txtMemo, Chr(10))
  12. Me.txtLine2 = Mid(txtMemo, VStart, Vend - VStart)
  13.  
Hi
I like to give more details about my query
The data is actually stored in the memo field of ms access table.
the data will look like below mentioned
always start and end with brackets
The lines starts with -
I want to extract certain data from this field and make it as one record with different fields
like field 1 as ALPHANUMERIC maximum 10 or 12
second field as data from the next line
third field as from next line like that
Hope it is clear pls help
Thanks in advance

(XXX-ALPHANUMERIC maximum 10 or 12/XX
-alphanumeric max 5/X-XXXXXXXX/X
-xxxxxxxx
-alphanumeric any number LIKEXXX 110 XXXDCXXXXXXV
XXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-xxxxxxxx XXXX XXXX
-XXX/XXXXXXXX XXXXXXXX ETC
XXXXXXXXXXXXXXX XXXX
-XXXXXXXXXXXXX
XXXXXXXXX
XXXXXXX)
Feb 13 '08 #6

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

Similar topics

1
by: ivan | last post by:
Access 97 I have a memo field in a footer on a subform. When I print the form, all data is printed except the data that was entered into the memo field. The memo field itself is printed (the...
1
by: Rose | last post by:
I have an ACCESS 2000 database and I have a table with a field setup as a MEMO. I am trying to run a query and append the MEMO field to another table - everytime I run the query - it drops data -...
13
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...
3
by: Helgardh | last post by:
I have a linked table (Access 2003) to an Outlook inbox. The body of the e-mail messages are in a memo field. My problem is that I need to "read" the memo and find data on certain lines. The...
5
by: kotowskil | last post by:
A report has a subform. The subform is set to datasheet view and its RecordSource is a select query that includes a memo field from the source table. The memo field's Can Grow property is Yes,...
3
by: MLH | last post by:
Precise determinations are not the objective. I would lke a single button click approach to creating a report/table/dynaset - whatever - to display each table name and an approx- imation of the...
9
by: RMC | last post by:
Hello, I'm looking for a way to parse/format a memo field within a report. The Access 2000 database (application) has an equipment table that holds a memo field. Within the report, the memo...
0
by: Grip | last post by:
Hi, I have gone throught the group and Microsoft's online help and have seen many suggestions but I am still seeking clarity: 1. I have an excel spreadsheet. Column A contains text that may...
15
by: sara | last post by:
I have a Memo field in a table to hold notes from a conversation a social worker has had with a client (this is for a non-profit). If the user needs to update the memo field, I need to find the...
3
by: Kunal Desale | last post by:
Hi, How to insert/update data in foxpro table field having datatype MEMO using Linked Server? I have written sql insert queries in which i have used linked server to insert data into foxpro...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.