Runtime error: '424' during Vaildation using BeforeUpdate

T

Tahlmorrah

I am getting a Runtime error: '424' Object Required with the following code:

Private Sub ParticipantName_BeforeUpdate(Cancel As Integer)
cmbxAccount = sAcc
tDate = dDate
[Call] = bCall + 1
If Me.[ParticipantName] Is Incorrect Then
MsgBox ("Particpant is not valid.")
[ParticipantName].Undo
DoCmd.GoToControl ("ParticipantName")
Cancel = True
End If

End Sub

If I Debug it jumps to 'If Me.[ParticipantName] Is Incorrect Then'. Do a
Mouse Over Me.[ParticipantName] = "Test Name 1" and
Mouse Over Incorrect = Empty. Most of the time a 424 means I do not have my
field names correct, but since debug is returning a value I know that is not
the case.

ParticipantName rule on table is Required only.

Code was suggested by Matthew DeAngelis in the question "Where to put
validation code on a form's module?" originally posted 8/18/2004 11:05 AM PST

I am now also told that Incorrect is not a standard VB or Access command
(but it does seem to be working as intended.

What am I doing wrong???? What can I use instead to validate this record?
 
T

Tahlmorrah

Interesting, for some reason my last Reply did not post.

Incorrect is part of a previous thead that I found with the title:
Subject: Re: Where to put validation code on a form's module? 8/18/2004
11:38 AM PST By: Matthew DeAngelis

---quote---
Hello,

You should place validating code in the BeforeUpdate event. I usually
do my validating by field, not by form, so I am not sure whether it can
be done at the recordset level. Validating by field looks something
like this:

Private Sub [FieldName]_BeforeUpdate(Cancel As Integer)

If Me.[FieldName] Is Incorrect Then
MsgBox ("[FieldName] is not valid.")
[Fieldname].Undo
Cancel = True
End If

End Sub


Hope this helps,
Matt

---end quote---

Wayne Morgan said:
What is "Incorrect"? Is it defined somewhere in your code?

--
Wayne Morgan
MS Access MVP


Tahlmorrah said:
I am getting a Runtime error: '424' Object Required with the following
code:

Private Sub ParticipantName_BeforeUpdate(Cancel As Integer)
cmbxAccount = sAcc
tDate = dDate
[Call] = bCall + 1
If Me.[ParticipantName] Is Incorrect Then
MsgBox ("Particpant is not valid.")
[ParticipantName].Undo
DoCmd.GoToControl ("ParticipantName")
Cancel = True
End If

End Sub

If I Debug it jumps to 'If Me.[ParticipantName] Is Incorrect Then'. Do a
Mouse Over Me.[ParticipantName] = "Test Name 1" and
Mouse Over Incorrect = Empty. Most of the time a 424 means I do not have
my
field names correct, but since debug is returning a value I know that is
not
the case.

ParticipantName rule on table is Required only.

Code was suggested by Matthew DeAngelis in the question "Where to put
validation code on a form's module?" originally posted 8/18/2004 11:05 AM
PST

I am now also told that Incorrect is not a standard VB or Access command
(but it does seem to be working as intended.

What am I doing wrong???? What can I use instead to validate this record?
 
W

Wayne Morgan

If Me.[FieldName] Is Incorrect Then

If that is an example that someone gave you and you're trying to follow, I
believe they were simply giving you a "generic" example, not exact syntax.
"Is Incorrect" is just English for which you need to substitute what
qualifies as "Incorrect" in your scenario. For example, if you only want
numbers less than 5, you would replace "Is Incorrect" with ">=5". A value of
5 or larger would be "incorrect" and would trigger the warning.

--
Wayne Morgan
MS Access MVP


Tahlmorrah said:
Interesting, for some reason my last Reply did not post.

Incorrect is part of a previous thead that I found with the title:
Subject: Re: Where to put validation code on a form's module? 8/18/2004
11:38 AM PST By: Matthew DeAngelis

---quote---
Hello,

You should place validating code in the BeforeUpdate event. I usually
do my validating by field, not by form, so I am not sure whether it can
be done at the recordset level. Validating by field looks something
like this:

Private Sub [FieldName]_BeforeUpdate(Cancel As Integer)

If Me.[FieldName] Is Incorrect Then
MsgBox ("[FieldName] is not valid.")
[Fieldname].Undo
Cancel = True
End If

End Sub


Hope this helps,
Matt

---end quote---

Wayne Morgan said:
What is "Incorrect"? Is it defined somewhere in your code?

--
Wayne Morgan
MS Access MVP


Tahlmorrah said:
I am getting a Runtime error: '424' Object Required with the following
code:

Private Sub ParticipantName_BeforeUpdate(Cancel As Integer)
cmbxAccount = sAcc
tDate = dDate
[Call] = bCall + 1
If Me.[ParticipantName] Is Incorrect Then
MsgBox ("Particpant is not valid.")
[ParticipantName].Undo
DoCmd.GoToControl ("ParticipantName")
Cancel = True
End If

End Sub

If I Debug it jumps to 'If Me.[ParticipantName] Is Incorrect Then'. Do
a
Mouse Over Me.[ParticipantName] = "Test Name 1" and
Mouse Over Incorrect = Empty. Most of the time a 424 means I do not
have
my
field names correct, but since debug is returning a value I know that
is
not
the case.

ParticipantName rule on table is Required only.

Code was suggested by Matthew DeAngelis in the question "Where to put
validation code on a form's module?" originally posted 8/18/2004 11:05
AM
PST

I am now also told that Incorrect is not a standard VB or Access
command
(but it does seem to be working as intended.

What am I doing wrong???? What can I use instead to validate this
record?
 

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

Top