By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,609 Members | 3,812 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,609 IT Pros & Developers. It's quick & easy.

Add to a memo field

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
"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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.