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

Add to a memo field

Hi All,
here is what I am trying to achieve. I have a memo field on a form which
users will need to add to as and when. I do not want them to be able to edit
information which already exists within this field.

My idea was to have the memo field locked on the form to stop edits.
Place a command button by the memo field which opens an unbound form with a
single text box.
The user enters their update into the unbound form and upon closing it, the
text they entered will be added to whatever information already exists
within the memo field.
I have tried running the following code upon click a command button on the
unbound form:

On Error GoTo UpdateMemoError
Dim strSQL As String

strSQL = "UPDATE tbl_IRS SET tbl_IRS.Details = " & _
"(SELECT tbl_IRS.Details FROM tbl_IRS " & _
"WHERE (((tbl_IRS.IR_Number)=[forms]![frm_IR_Entry]![IR_Number]));) &
[forms]![frm_memo_Update]![xt_Addition] " & _
"WHERE (((tbl_IRS.IR_Number)=[forms]![frm_IR_Entry]![IR_Number]));"

DoCmd.RunSQL strSQL

UpdateMemoExit:
Exit Sub

UpdateMemoError:
Debug.Print "Error Description: " & Err.Description & vbCrLf & _
"Error Number: " & Err.Number
Resume UpdateMemoExit
but recieve the following error:

Error Description: Invalid Memo, OLE, or Hyperlink Object in subquery
'tbl_IRS.Details'.
Error Number: 3342

The help file says "
A subquery cannot return a Memo or OLE Object, and it cannot be compared to
a Memo or OLE Object in an expression." but I can't think of another way to
do this :o(
Am I barking up the wrong tree in the way I am trying to do this or is it
simply my syntax is incorrect?

TIA,

Mark
May 10 '06 #1
4 7205
"Mark Reed" <ma*********@ntlworld.com> wrote in message
news:XB******************@newsfe2-gui.ntli.net...
Hi All,
here is what I am trying to achieve. I have a memo field on a form
which users will need to add to as and when. I do not want them to be able
to edit information which already exists within this field.


Hi Mark, this is how I do it (you'll have to rename objects as necessary and
I have three remarks memo fields to handle which I pass the names to in the
call's OpenArgs):

In your command button's Click event in your 'append' form:

If MsgBox("Are you sure?", vbYesNo, gcApplication) = vbNo Then Exit Sub

Dim strUser As String
strUser = libUserName

Dim db As DAO.Database, rs As DAO.Recordset, strSQL As String, strCriteria
As String, strFieldName As String
Set db = CurrentDb
strSQL = "Select * from qryRemarks;"
strFieldName = Me.OpenArgs
strCriteria = "[IssueNo] = " & Forms(gcFrmMain)!txtIssueNo '**This is the
record's unique ID **

Set rs = db.OpenRecordset(strSQL)
With rs
.FindFirst strCriteria
.Edit
If IsNull(rs(strFieldName)) Then
rs(strFieldName) = "(" & strUser & ": " & Me.txtAppend & ")"
Else
rs(strFieldName) = rs(strFieldName) & " (" & strUser & ": " &
Me.txtAppend & ")"
End If
.Update
End With
rs.Close
Set rs = Nothing

*** END CODE ***

HTH - Keith.
www.keithwilby.com
May 10 '06 #2
On Wed, 10 May 2006 07:27:51 GMT, Mark Reed wrote:
Hi All,
here is what I am trying to achieve. I have a memo field on a form which
users will need to add to as and when. I do not want them to be able to edit
information which already exists within this field.

My idea was to have the memo field locked on the form to stop edits.
Place a command button by the memo field which opens an unbound form with a
single text box.
The user enters their update into the unbound form and upon closing it, the
text they entered will be added to whatever information already exists
within the memo field.

I have tried running the following code upon click a command button on the
unbound form:

On Error GoTo UpdateMemoError
Dim strSQL As String

strSQL = "UPDATE tbl_IRS SET tbl_IRS.Details = " & _
"(SELECT tbl_IRS.Details FROM tbl_IRS " & _
"WHERE (((tbl_IRS.IR_Number)=[forms]![frm_IR_Entry]![IR_Number]));) &
[forms]![frm_memo_Update]![xt_Addition] " & _
"WHERE (((tbl_IRS.IR_Number)=[forms]![frm_IR_Entry]![IR_Number]));"

DoCmd.RunSQL strSQL

UpdateMemoExit:
Exit Sub

UpdateMemoError:
Debug.Print "Error Description: " & Err.Description & vbCrLf & _
"Error Number: " & Err.Number
Resume UpdateMemoExit

but recieve the following error:

Error Description: Invalid Memo, OLE, or Hyperlink Object in subquery
'tbl_IRS.Details'.
Error Number: 3342

The help file says "
A subquery cannot return a Memo or OLE Object, and it cannot be compared to
a Memo or OLE Object in an expression." but I can't think of another way to
do this :o(

Am I barking up the wrong tree in the way I am trying to do this or is it
simply my syntax is incorrect?

TIA,

Mark


I would do it this way.
No SQL needed.

1) Set the Memo control's Locked property to Yes.

2) Add an unbound Text control to your existing form.
Size it as large as you wish.
You can place it on top of any existing controls on this form.
Set it's Visible property to No.
Name this control "AddToMemo"

Code it's AfterUpdate event:
Me![YourMemo] = Me![YourMemo] & " " & Me![AddToMemo]
Me![AddToMemo] = Null
Me![AnyOtherControl].SetFocus
Me![AddToMemo].Visible = False
=========

Code your command button click event:
Me![AddToMemo].Visible = True
Me![AddToMemo].SetFocus
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
May 10 '06 #3
Thank you both for your suggestions. I went with Keith's suggestion in the
end although I can see both would work.

Thanks again for your time. Very much appreciated,

Mark
"Keith Wilby" <he**@there.com> wrote in message
news:44**********@glkas0286.greenlnk.net...
"Mark Reed" <ma*********@ntlworld.com> wrote in message
news:XB******************@newsfe2-gui.ntli.net...
Hi All,
here is what I am trying to achieve. I have a memo field on a form
which users will need to add to as and when. I do not want them to be
able to edit information which already exists within this field.


Hi Mark, this is how I do it (you'll have to rename objects as necessary
and I have three remarks memo fields to handle which I pass the names to
in the call's OpenArgs):

In your command button's Click event in your 'append' form:

If MsgBox("Are you sure?", vbYesNo, gcApplication) = vbNo Then Exit Sub

Dim strUser As String
strUser = libUserName

Dim db As DAO.Database, rs As DAO.Recordset, strSQL As String, strCriteria
As String, strFieldName As String
Set db = CurrentDb
strSQL = "Select * from qryRemarks;"
strFieldName = Me.OpenArgs
strCriteria = "[IssueNo] = " & Forms(gcFrmMain)!txtIssueNo '**This is the
record's unique ID **

Set rs = db.OpenRecordset(strSQL)
With rs
.FindFirst strCriteria
.Edit
If IsNull(rs(strFieldName)) Then
rs(strFieldName) = "(" & strUser & ": " & Me.txtAppend & ")"
Else
rs(strFieldName) = rs(strFieldName) & " (" & strUser & ": " &
Me.txtAppend & ")"
End If
.Update
End With
rs.Close
Set rs = Nothing

*** END CODE ***

HTH - Keith.
www.keithwilby.com

May 10 '06 #4
fredg <fg******@example.invalid> wrote in
news:ow*****************************@40tude.net:
On Wed, 10 May 2006 07:27:51 GMT, Mark Reed wrote:
Hi All,
here is what I am trying to achieve. I have a memo field
on a form which
users will need to add to as and when. I do not want them to
be able to edit information which already exists within this
field.

My idea was to have the memo field locked on the form to stop
edits. Place a command button by the memo field which opens
an unbound form with a single text box.
The user enters their update into the unbound form and upon
closing it, the text they entered will be added to whatever
information already exists within the memo field.

I have tried running the following code upon click a command
button on the unbound form:
[ code and error messages snipped ]
Am I barking up the wrong tree in the way I am trying to do
this or is it simply my syntax is incorrect?

TIA,

Mark


I would do it this way.
No SQL needed.

1) Set the Memo control's Locked property to Yes.

2) Add an unbound Text control to your existing form.
Size it as large as you wish.
You can place it on top of any existing controls on this form.
Set it's Visible property to No.
Name this control "AddToMemo"

Code it's AfterUpdate event:
Me![YourMemo] = Me![YourMemo] & " " & Me![AddToMemo]
Me![AddToMemo] = Null
Me![AnyOtherControl].SetFocus
Me![AddToMemo].Visible = False
=========

Code your command button click event:
Me![AddToMemo].Visible = True
Me![AddToMemo].SetFocus


You can modify fred's concept to use your unbound modal form to
write the data back to the mainform control.

In the unbound form's UpdateMemo event, instead of the
Me![YourMemo] reference, just use the full reference to the form
Forms![YourMainForm]![YourMemo] = _
Forms![YourMainForm]![YourMemo] _
& vbNewline & vbnewline & now() &": " _
&Me!addtoMemo
me!close
--
Bob Quintal

PA is y I've altered my email address.
May 10 '06 #5

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

Similar topics

6
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...
3
by: GorDon | last post by:
Hi, I have a report based on a query. The query grabs a memo field from my main table, yet when I display the memo field in the report it truncates the memo field (the field needs to hold more...
2
by: Bob Dydd | last post by:
Hi Everybody I have a Listbox that has a Memo field attached to it's 2nd column which on double click copies the memo field to another Memo Field. Forms!! = ListClassification.Column(1) My...
2
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...
1
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...
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...
2
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...
10
by: ARC | last post by:
This is mainly a speed question. In this example: I have a QuotesHdr table that has a few memo fields. If these memo fields are used extensively by some users, and if their are a large number of...
11
tdw
by: tdw | last post by:
Hi all, I have tried a few different methods to accomplish this, but with no luck. I will post the code for the latest attempt at the end of this post. I work at a land surveying company. This...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.