473,703 Members | 2,666 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:


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.



Jul 29 '06 #1
1 3043
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:


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.


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
'we have more cr/lf's
s = Mid(s, i + 2)
End If
'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
End If
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

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 corrupted. Don't know if it's clear enough.
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, ShyGuy
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 can be just a few words, and some can be tens or hundreds of lines, and I've realised that zooming...
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 option listed when exporting). I then opened the .rtf file in Word. However, it looks like some...
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.
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 view text above/below the displayed window? I'm looking for a sort of dynamic autosize.
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 addrs show up as the person's name (John Doe) and an eMail type hyperlink is in place behind the...
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, " & _ "AFirst, Price, ALast, MainPhoto, Summary, Details,
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 odbc data source) it is linked as a memo field
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 most users, this new feature is actually very convenient. If you want to control the update process,...
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.