473,748 Members | 7,142 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 3052
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
8689
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.
6
10474
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
2
4721
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...
4
22767
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...
3
3032
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
5750
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.
7
1861
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...
6
2710
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,
2
3384
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
0
8830
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,...
0
9370
jinu1996
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...
1
9321
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,...
0
9247
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8242
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6074
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();...
1
3312
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
2
2782
muto222
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.