473,786 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DLookup("[PVIN]", "tblPreliminary VINs", "[PVIN]=Forms!frmVINOD O!SerialNum")

MLH
DLookup("[PVIN]", "tblPreliminary VINs",
"[PVIN]=Forms!frmVINOD O!SerialNum")

is giving me a Type Mismatch error. That's confusing to me
and I don't know how to circumvent it. The [PVIN] field in
tblPreliminaryV INs is a 17-char text field. Forms!frmVINODO !SerialNum
is just an unbound textbox on a form (frmVINODO).

I run the DLookup during the textbox's BeforeUpdate event code. Some
VIN values I type in there do NOT give rise to the error. Some do. By
nature, the VIN values are alphanumeric. Should I be wrapping the
Forms!frmVINODO !SerialNum in CStr( ) or something?
Jan 11 '06
11 2231
MLH
On 11 Jan 2006 16:09:43 -0800, "Lyle Fairfield"
<ly***********@ aim.com> wrote:
IF must have something it can coerce into a Boolean. VBA can coerce a
Null into a Boolean. So IF has no problem when DLookup finds nothing
and returns a Null. But when DLookup finds something and returns a
string, IF does have a problem; VBA cannot coerce a string into a
Boolean (unless the string is recognizable as a Boolean, eg "True").

It is your IF that is causing the problem, not your DLookup.
Possibly
IF Nz(DLookup("[PVIN]", "tblPreliminary VINs", "[PVIN]='" &
Forms!frmVINOD Otesting!Serial Num & "'"), "") <> "" Then

or

IF Not IsNull(DLookup( "[PVIN]", "tblPreliminary VINs", "[PVIN]='" &
Forms!frmVINOD Otesting!Serial Num & "'")) Then

<snip>
Both good suggestions. Dunno what was wrong with me, but I
had a bad case of it. Thx for setting me straight.
Jan 12 '06 #11
MLH <CR**@NorthStat e.net> wrote in
news:7d******** *************** *********@4ax.c om:
On Thu, 12 Jan 2006 00:18:07 GMT, "Randy Harris"
<ra***@SpamFree .com> wrote:
BTW - I would strongly recommend that you get out of the habit
of using GetKeys. There is almost always a better
alternative .

Yeah, the sendkeys thing - I'm using to clear
Forms!frmVINODO testing!SerialN um. Seems
like an easy way. Its an unbound textbox. Whats
your best recommendation - I hate sendkeys too.

me.undo

--
Bob Quintal

PA is y I've altered my email address.
Jan 12 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

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.