|
 |
access thread: Data type mismatch in criteria expression.
Message #1 by "John Aksoy" <john@j...> on Mon, 28 Oct 2002 16:24:20
|
|
Hi,
I have developed a small order entry system in Access and wanted to
automatically display the price when I select the SKU (Item Number). I
used the below code and get "Data type mismatch in criteria expression."
error. My SKU field in my InventroyMaster table is TEXT type and in
OrderDetails SKU is TEXT type as well. I need a conversion function i
guess to convert the below TicketPrice to currency. Please review my code
below and see how I can fix this. I also tryied to change my SKU from TEXT
to NUMBER in InventoryMaster and OrderDetail tables and it works, but I
need to keep the SKU field as text. strFilter is were its complianing and
I need to convert this i guess.
CODE USED
***********************************************************************
Private Sub SKU_AfterUpdate()
On Error GoTo Err_SKU_AfterUpdate
Dim strFilter As String
' Evaluate filter before it's passed to DLookup function.
strFilter = "SKU = " & Me!SKU
' Look up product's unit price and assign it to UnitPrice control.
Me!TicketPrice = DLookup("TicketPrice", "tblInventoryMaster",
strFilter)
Exit_SKU_AfterUpdate:
Exit Sub
Err_SKU_AfterUpdate:
MsgBox Err.Description
Resume Exit_SKU_AfterUpdate
End Sub
************************************************************************
Thanks,
John Aksoy
Message #2 by "Gregory Serrano" <SerranoG@m...> on Mon, 28 Oct 2002 16:31:32
|
|
John,
You said SKU was text. Therefore, change:
strFilter = "SKU = " & Me!SKU
to:
strFilter = "SKU = '" & Me!SKU & "'"
Greg
Message #3 by "Hamilton. Tom" <hamiltont@s...> on Mon, 28 Oct 2002 08:23:21 -0800
|
|
You need the single quote character to identify the type
strFilter =3D "SKU =3D '" & Me!SKU & "'"
Tom Hamilton
T_Systems, Inc
(xxx) xxx-xxxx
-----Original Message-----
From: John Aksoy [mailto:john@j...]
Sent: Monday, October 28, 2002 8:24 AM
To: Access
Subject: [access] Data type mismatch in criteria expression.
Hi,
I have developed a small order entry system in Access and wanted to
automatically display the price when I select the SKU (Item Number). I
used the below code and get "Data type mismatch in criteria expression."
error. My SKU field in my InventroyMaster table is TEXT type and in
OrderDetails SKU is TEXT type as well. I need a conversion function i
guess to convert the below TicketPrice to currency. Please review my
code
below and see how I can fix this. I also tryied to change my SKU from
TEXT
to NUMBER in InventoryMaster and OrderDetail tables and it works, but I
need to keep the SKU field as text. strFilter is were its complianing
and
I need to convert this i guess.
CODE USED
***********************************************************************
Private Sub SKU_AfterUpdate()
On Error GoTo Err_SKU_AfterUpdate
Dim strFilter As String
' Evaluate filter before it's passed to DLookup function.
strFilter =3D "SKU =3D " & Me!SKU
' Look up product's unit price and assign it to UnitPrice control.
Me!TicketPrice =3D DLookup("TicketPrice", "tblInventoryMaster",
strFilter)
Exit_SKU_AfterUpdate:
Exit Sub
Err_SKU_AfterUpdate:
MsgBox Err.Description
Resume Exit_SKU_AfterUpdate
End Sub
************************************************************************
Thanks,
John Aksoy
|
|
 |