473,544 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pasting 1st line of memo field to a text field (revisited)

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([MemoField],instr(1,[MemoField],vbCrLf)-1)

This is great, but I would like to do this on a form, so that the
person entering the memo can use a button to paste the 1st line to a
title (text) field. I'm having trouble setting up the code to do this.
I'd also appreciate some ideas on how to get the 2nd and 3rd lines
copied to other fields.

Thanks

Alex

Jul 29 '06 #1
1 3012
al****@msn.com. au wrote:
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([MemoField],instr(1,[MemoField],vbCrLf)-1)

This is great, but I would like to do this on a form, so that the
person entering the memo can use a button to paste the 1st line to a
title (text) field. I'm having trouble setting up the code to do this.
I'd also appreciate some ideas on how to get the 2nd and 3rd lines
copied to other fields.

Thanks

Alex
Here's some code you can modify. This opens up a table called Table3
and reads 2 records in this table that have memos. You can change the
count if you like.

It attempts to read and display the first 3 lines of the memo before
moving on to the next record. If there are only 1 or 2 lines, it
displays them then goes on to the next record.

It's possible that at the end of the memo the operator hits the tab key.
This will not have a CR/LF at the end.

When you read the memo in your form, in the AfterUpdate event you can
run the modified code I have provided. With the variable "i" you can
assign the result "s" string to Text1, Text2, or Text3 depending on
"i's" value.

You can copy this code into a code module. Then change the table name
and memo field name in the code below. It will run fine and demo how do
do what you want.

Sub abcdef()
Dim r As DAO.Recordset
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim s As String

'change Table3 to your table name
Set r = CurrentDb.OpenR ecordset("Table 3", dbOpenSnapshot)

Do While Not r.EOF
If Not IsNull(r!memoF) Then
k = k + 1 'record counter

'only check 2 records
If k = 3 Then Exit Do

'change all MemoF refs in this code to
'your memo field name
s = r!memoF 'assign to the string var

For j = 1 To 3
'find the first CR/LF
i = InStr(s, vbNewLine)

If i 0 Then
'it found a crlf
MsgBox k & " " & j & " " & Left(s, i - 1)
If i + 2 >= Len(r!memoF) Then
'there are no move cr/lf's
Exit For
Else
'we have more cr/lf's
s = Mid(s, i + 2)
End If
Else
'there was either 1 cr/lf or else this
'has no cr/lf left because of the tab
'key being pressed
MsgBox k & " " & j & " " & s
Exit For
End If
Next
End If
r.MoveNext
Loop
r.Close
Set r = Nothing
MsgBox "Done"
End Sub

Jul 29 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
8645
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 field in plain text. That's because I truncate the string text but if, when I truncate it there's a rich tag the code following the truncated string is...
6
10444
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 field, and it works. But, it seems wrong since I had to create a huge text box to accommodate memo fields with a lot of text. Thanks for any help,...
2
4707
by: Jeremy | last post by:
I have a pretty straightforward database that is designed to record free-form information about products (date, source and a memo field). This is searched and updated via a form. For new records, the memo field is usually filled by cutting and pasting from e-mails, web content and spreadsheets. The only problem is that some of the memos...
4
22736
by: intl04 | last post by:
I have a memo field that is included in some Access reports I created. Is there some way for the memo field to display nicely formatted text, with line breaks between paragraphs? Or is it necessary to export the report? I tried exporting a report by using the .rtf rich-text format (the plain-text format was the only other word-processing...
3
3018
by: John | last post by:
I have a field, data type Memo, in a job details table. I have a text box on a report which I need to print the contents of this field. My problem is that the text box will only display 255 characters. How can I get the report to print this field completely. Thanks for any help out there. John.
2
5729
by: Kevin | last post by:
Thanks for the very quick response posting that I can use a memo datatype to store large amounts of text. I understand that I can turn on "Can Grow" for a memo type, but is there either a property or VB code that will allow the text box to expand vertically as the user adds lines, so that it isn't necessary to use the vertical scroll bar to...
7
1855
by: MLH | last post by:
I have a several hundred contact info entries in an MS Word document (name / addr / phone / email / website) - the usual sort of thing. I want to put the data into an A97 table. In my Word document, a URL typed in shows up as a hyperlink. Cutting & pasting preserves the URL because they're typed in literally. On the other hand, the eMail...
6
2688
by: Matt | last post by:
I'm having difficulty with trying to update a Access memo field through an SQL statement where the value I'm trying to pass is longer than 255 characters. The field is being truncated. I'm using a simple INSERT INTO sql command. Anyone know a way around this? Sample strSQL = "INSERT INTO tblListings " & _ "(Dir, Street, City, State, "...
2
3367
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 table today, it is linked as a text(255) field, ditto for the first table if I link it today if I link the 2nd table using access2003 (and the same...
0
7416
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7360
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7363
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7701
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5899
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5289
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4906
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1833
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
653
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.