Validate a Memo field

M

Matt

I am trying to validate the contents of a memo field on a form when a key is pressed, this only seems to work after the record is saved and then navigated back to. My sample is below, I want to ensure that there is something in the field before the record is updated.

If Me.Mymemo is "" The
MsgBox("You must enter a note"
End If

Is there something special that needs to be done with a memo field before it's contents can be checked, or is there another way of doing this

Thank
Matt
 
T

tina

i'm not sure where you're running your code from; i would use the form's
BeforeUpdate event, as

Private Sub Form_BeforeUpdate(Cancel As Integer)

If IsNull(Me!MemoFieldName) Or Me!MemoFieldName = "" Then
Cancel = True
Me!MemoFieldName.SetFocus
MsgBox "Please enter a value in the memo field."
End If

End Sub

hth


Matt said:
I am trying to validate the contents of a memo field on a form when a key
is pressed, this only seems to work after the record is saved and then
navigated back to. My sample is below, I want to ensure that there is
something in the field before the record is updated.
If Me.Mymemo is "" Then
MsgBox("You must enter a note")
End If

Is there something special that needs to be done with a memo field before
it's contents can be checked, or is there another way of doing this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Format Memo field 4
memo field to .txt file 1
Write to a Memo Field 1
Search and update with a combo box 1
subform and memo fields 4
Force Update of Subform Data 0
start a new line in a memo field 1
programming 6

Top