Validate a Memo field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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?
 
Back
Top