Strange error with Option Explicit

  • Thread starter Nicholas Scarpinato
  • Start date
N

Nicholas Scarpinato

Can anyone explain why using Option Explicit would case the following line to
error out saying "Variable Not Defined":

If CountDen > 0 Then DoCmd.SendObject , , , "(e-mail address removed)", , ,
"Items were rejected on initial RA submission form.", "Items were rejected by
" & VendorID & " on the initial submission of the following batch: " &
Chr(13) & Me![Batch Selection] & Chr(13) & Chr(13) & "Please review the
rejected items.", No

If I leave Option Explicit out, the code works fine. With it in, I get an
error saying that "No" is not defined. Any ideas (other than the obvious of
just running the code without Option Explicit)?
 
M

Marshall Barton

Nicholas said:
Can anyone explain why using Option Explicit would case the following line to
error out saying "Variable Not Defined":

If CountDen > 0 Then DoCmd.SendObject , , , "(e-mail address removed)", , ,
"Items were rejected on initial RA submission form.", "Items were rejected by
" & VendorID & " on the initial submission of the following batch: " &
Chr(13) & Me![Batch Selection] & Chr(13) & Chr(13) & "Please review the
rejected items.", No

If I leave Option Explicit out, the code works fine. With it in, I get an
error saying that "No" is not defined. Any ideas (other than the obvious of
just running the code without Option Explicit)?


"No" is not a built-in value, you are supposed to use False
instead.

If you must use No, then declare it in the module:

Const No As Boolean =False

so OPTION EXPLICIT doesn't complain about the undefined name
(personally, I think this would be a poor programming
practice).
 

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