473,813 Members | 3,718 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checking If Memo Field Updated on Form

13 New Member
I am trying to check if notes have been added to a Memo field on a form if certain other fields have changed. Example: If the user ticks a particular check box on the form, I want to force them to add some note detailing the change before the will be allowed to save the record.

I have the checks on the other fields working. What I can't seem to find an effective method for is checking whether the user has added notes to the Memo field on the form.

I've tried:

Expand|Select|Wrap|Line Numbers
  1. If Me.Q1_Comp_Check.Value <> Me.Q1_Comp_Check.OldValue Then
  2.  
  3.     If Me.txtSiteNotes.Value = Me.txtSiteNotes.OldValue Then
  4.  
  5. MsgBox "You Must Enter Notes Before You Can Save This Record", vbOKOnly
  6.  
  7. Me.txtAddNote.SetFocus
  8. DoCmd.CancelEvent
  9.  
  10. Exit Sub
  11. End If
  12. End If
However, I get a Runtime 3251 error that the Operation Is not Supported For This Type Of Object. I'm guessing this is because the .Value operator is invalid when used with a Memo-type field.

So, any recommendations as to how I can determine if a Memo-type field has been updated before a record is saved?

Thanks in advance for any assistance.

Regards,
Garrett
Apr 3 '08 #1
6 2754
missinglinq
3,532 Recognized Expert Specialist
"I'm guessing this is because the .Value operator is invalid when used with a Memo-type field"

The datatype, which in this case is memo field, has nothing to do with the .Value property! The property is the property of the textbox control that holds the memo field data, not the property of the memo field!

I suspect the problem is with the line

DoCmd.CancelEve nt


You don't say what event you have your code in, but not all events can be cancelled, as you're trying to do here. They way to determine whether an event can be cancelled is to check the first line of the event.

These two events

Private Sub Form_Load()

Private Sub Form_AfterUpdat e()

can't be cancelled, but

Private Sub Form_BeforeUpda te(Cancel As Integer)

can be cancelled, as indicated by the argument Cancel As Integer.

Also note that you can't force this by placing Cancel As Integer in the argument list of an event that Access doesn't place it in, such as

Private Sub Form_Load(Cancel As Integer)

Won't work, and is a good reason for never typing in the title line of a sub if it's one of the standard events that is accessable thru the (General) dropdown box in the code module.

Myself and half a dozen other experienced people spent many hours one nite trying to figure out why a very simple sub

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Close(Cancel As Integer)
  2.   Msgbox "Closing this Form!"
  3. End Sub
kept erroring out, until someone finally noticed that Cancel As Integer was out of place!The OP had simply manually typed in the code, copying the style from a nearby sub, including the Cancel As Integer, which wasn't appropriate for the Form_Close event.

If the event you have the code in is one that can be cancelled, let us know and we'll look at it again.

Welcome to bytes!

Linq ;0)>
Apr 4 '08 #2
maxx429
13 New Member
"I'm guessing this is because the .Value operator is invalid when used with a Memo-type field"

The datatype, which in this case is memo field, has nothing to do with the .Value property! The property is the property of the textbox control that holds the memo field data, not the property of the memo field!

I suspect the problem is with the line

DoCmd.CancelEve nt


You don't say what event you have your code in, but not all events can be cancelled, as you're trying to do here. They way to determine whether an event can be cancelled is to check the first line of the event.

These two events

Private Sub Form_Load()

Private Sub Form_AfterUpdat e()

can't be cancelled, but

Private Sub Form_BeforeUpda te(Cancel As Integer)

can be cancelled, as indicated by the argument Cancel As Integer.

Also note that you can't force this by placing Cancel As Integer in the argument list of an event that Access doesn't place it in, such as

Private Sub Form_Load(Cancel As Integer)

Won't work, and is a good reason for never typing in the title line of a sub if it's one of the standard events that is accessable thru the (General) dropdown box in the code module.

Myself and half a dozen other experienced people spent many hours one nite trying to figure out why a very simple sub

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Close(Cancel As Integer)
  2.   Msgbox "Closing this Form!"
  3. End Sub
kept erroring out, until someone finally noticed that Cancel As Integer was out of place!The OP had simply manually typed in the code, copying the style from a nearby sub, including the Cancel As Integer, which wasn't appropriate for the Form_Close event.

If the event you have the code in is one that can be cancelled, let us know and we'll look at it again.

Welcome to bytes!

Linq ;0)>

Sorry, I guess I wasn't clear.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.  
  3.    If Me.Q1_Comp_Check.Value <> Me.Q1_Comp_Check.OldValue Then
  4.  
  5.           If Me.txtSiteNotes.Value = Me.txtSiteNotes.OldValue Then
  6.  
  7.       MsgBox "You Must Enter Notes Before You Can Save This Record", vbOKOnly
  8.  
  9.       Me.txtAddNote.SetFocus
  10.  
  11.       DoCmd.CancelEvent
  12.  
  13.       Exit Sub
  14.       End If
  15.       End If
This should be clearer now. The above code is being executed in the Form's BeforeUpdate event.

DoCmd.CancelEve nt is intended to Cancel the update if the user has ticked the Q1_Comp_Check box and has NOT updated the txtSiteNotes field.

The first line of code checks to see if the Value of Q1_Comp_Check is different from the OldValue. If it is, the second line is attempting to check if the value of txtSiteNotes has changed, indicating that the user added some sort of note.

What I need is a way of determining if txtSiteNotes has changed.

The Runtime error is being generated on this line of code:

Expand|Select|Wrap|Line Numbers
  1. If Me.txtSiteNotes.Value = Me.txtSiteNotes.OldValue Then
Since I am not getting an error on this,

Expand|Select|Wrap|Line Numbers
  1. If Me.Q1_Comp_Check.Value <> Me.Q1_Comp_Check.OldValue Then
that seems to indicate that I cannot compare .Value to .OldValue on that type of field.

I hope that clears things up. I think I may have included too much information. :) All I really need is a way to determine if a Memo field's contents have changed.

Thanks again.

Garrett
Apr 4 '08 #3
maxx429
13 New Member
Bumping this on the off chance it was missed the first time around. :)

If there is not an effective way to check if my Memo field has been updated, does anyone have a suggestion as to how I can ensure that the user adds a note whenever certain fields on the Form are changed? I can't be the only person to have needed this sort of functionality, right?

I've considered using and Add Notes button and trying to trap whenever it is clicked, but I cannot seem to come up with away to do that.

Understand that I am not a professional developer. I'm simply the closest we have in my little company. :)

Thanks again for any help yo guys can offer.

Regards,
Garrett
Apr 7 '08 #4
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. I've tested the comparison of value to oldvalue on a memo field of my own using a version of your code without any run-time error at all. The test memo had 799 characters, so was much bigger than a normal text string.

I can't explain the error you are experiencing; it works fine for me.

You could find out more about the conditions at the time of the error by setting a breakpoint at the beginning of your code and using debug.print to print the oldvalue and current value of the notes field, and its length (using the len() function to do so). It will all help to understand why this is happening for you when it is not happening for me.

-Stewart
Apr 7 '08 #5
missinglinq
3,532 Recognized Expert Specialist
I've duplicated this entire thing and I, like Stewart, have no problem with it working the way you intend! I suppose we have to consider some form of corruption.

The only other thing I've noted is that you set focus to a control named txtAddNote. Is this a way of indirectly adding data to your txtSiteNotes control?

Linq ;0)>
Apr 7 '08 #6
maxx429
13 New Member
I've duplicated this entire thing and I, like Stewart, have no problem with it working the way you intend! I suppose we have to consider some form of corruption.

The only other thing I've noted is that you set focus to a control named txtAddNote. Is this a way of indirectly adding data to your txtSiteNotes control?

Linq ;0)>

Thanks to both Stewart and Linq for looking at this.

In answer to Linq's question, the txtAddNote control is an unbound Text Box where the user enters any new notes. These notes are then appended, using code on a Command Button, to the txtSiteNotes control which is a bound control tied to a Memo field in the table to which the Form is bound.

I'm not sure if this will help, but here is a bit of additional information:

This is the code on the Command button used to append new notes to txtSiteNotes control:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAddNotes_Click()
  2. If IsNull(Me.txtAddNote) Then
  3.  
  4. MsgBox "Please Enter A Valid Note To Be Saved", vbOKOnly
  5.  
  6. Me.txtAddNote.SetFocus
  7.  
  8. Exit Sub
  9. End If
  10.  
  11. Dim rs As Recordset, frm As Form, m As Long, str1 As String, CurForm As String
  12.  
  13. CurForm = Me.Name
  14.  
  15. Set frm = Me.Form
  16. Set rs = frm.RecordsetClone
  17. m = frm.CurrentRecord
  18. rs.MoveFirst
  19. rs.Move (m - 1)
  20.  
  21. If IsNull(rs!Site_Notes) Then
  22.  
  23. str1 = Me.txtAddNote & " " & _
  24. Format(Now(), "dd mmm yy at hh:nn:ss ampm") & " by " & NetworkUserName
  25. rs.Edit
  26. Me.Site_Notes = str1
  27. Me.txtAddNote = ""
  28. rs.Update
  29.  
  30. Else
  31.  
  32. str1 = rs!Site_Notes
  33.  
  34. str1 = str1 & vbCrLf & Me.txtAddNote & " " & _
  35. Format(Now(), "dd mmm yy at hh:nn:ss ampm") & " by " & NetworkUserName
  36. rs.Edit
  37. Me.Site_Notes = str1
  38. Me.txtAddNote = ""
  39. rs.Update
  40.  
  41. End If
  42. End Sub
I'm using Access 2007, but the database I am working in is formatted as Access 2000.

I have tested using the .Value and .OldValue properties on multiple Text Controls on the same form and had no issues. I only get the Runtime error about the Operation Is Not Supported for This type Of Object when I attempt to compare Value to OldValue on the Memo field.

Thanks for looking.

Garrett
Apr 8 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
10481
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
4723
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...
2
2512
by: PMB | last post by:
Thank you in advance for any and all assistance. I'm trying to input data from strings to a memo field. I would like to know how to check first to see if there is text there currently and if so move to the end and input the new text. Also, would like to know if I can change the justification on each line of text as it's entered. i.e. Company Name, address, city state and zip would be centered and all the
4
5409
by: Mal | last post by:
I have an ACC 2000 database that has a strange behaviour I have a small table, with just a few fields... My report has very simple grouping and sorting, no code bar a NODATA event. I have a memo field When CAN GROW is set to NO everything works just fine. When CAN GROW is set to YES - watch out.... One record causes BIG
4
7246
by: Mark Reed | last post by:
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...
3
2353
by: Roy | last post by:
Hi All, I have a table in A2K application.I get a memo field via download from a .csv file.The contents are as below: field name is TicketStatus, For example,a single ticket,TicketID 12345 has a track history contained in TicketStatus field.It starts right from problem opened until problem closed with date/time.
10
3061
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 records in QuotesHdr, should I break out the memo fields into a separate table? The thinking here is that, for Quotes selection dropdowns that display all entries in QuotesHdr for selection, I would think that the entire record comes down over...
11
3741
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 database is for tracking survey orders. One of the fields is for entering the Subdivision that the parcel of land is in. That field on the New Orders entry form is called "SUB_NAME". On that form it is a combo box that uses a seperate table called...
3
9391
by: Kunal Desale | last post by:
Hi, How to insert/update data in foxpro table field having datatype MEMO using Linked Server? I have written sql insert queries in which i have used linked server to insert data into foxpro tables. Some fields have datatype Memo and in these fields my data is not getting inserted/updated. My queries contains local tables & dbf tables (Both). I try simple insert query which insert data into one memo field in foxpro editor and sql...
0
9734
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9607
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
10140
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
9224
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
7684
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
5706
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4358
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
3885
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3030
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.