473,508 Members | 2,289 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Data type mismatch

N J
Hi,

CurrentDb.Execute "Update tblDelayedOrders Set DELAYED = True Where ID = " &
Me.txtOrderNumber & ";", dbfailonerror
Me.StatusListBox.AddItem "ORDER # " & Me.txtOrderNumber & " MARKED AS
DELAYED " & "" & "", 0

When I change Where ID to Where TRACKING (another text field) I get the
error Data Type Mismatch in expression critera, or something like that

Help :(
ta
Nov 13 '05 #1
4 3131
By assigning txtOrderNumer to field TRACKING which is text.. could that
possibly be messing it up?

Nov 13 '05 #2
N J
I don't think this could be the reason? it is just a name.

"Beacher" <be*****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
By assigning txtOrderNumer to field TRACKING which is text.. could that
possibly be messing it up?

Nov 13 '05 #3
Beacher is on the right track. The syntax needs to change to handle a value
assigned to a Text data type field.

CurrentDb.Execute "Update tblDelayedOrders Set DELAYED = True Where TRACKING
= '" &
Me.txtOrderNumber & "';", dbfailonerror

Note the addition of the single quotes to delimit the value
Me.txtOrderNumber. Even though this may be a number, you are assigning it to
a text field and it will need to be treated as text. If the value can have
apostrophes in it, the syntax will need to be modified more.

--
Wayne Morgan
MS Access MVP
"N J" <bl*************@blueyonder.co.uk> wrote in message
news:VT*******************@fe3.news.blueyonder.co. uk...
Hi,

CurrentDb.Execute "Update tblDelayedOrders Set DELAYED = True Where ID = "
& Me.txtOrderNumber & ";", dbfailonerror
Me.StatusListBox.AddItem "ORDER # " & Me.txtOrderNumber & " MARKED AS
DELAYED " & "" & "", 0

When I change Where ID to Where TRACKING (another text field) I get the
error Data Type Mismatch in expression critera, or something like that

Help :(
ta

Nov 13 '05 #4
"Wayne Morgan" <co***************************@hotmail.com> wrote in message
news:iz****************@newssvr11.news.prodigy.com ...
Beacher is on the right track. The syntax needs to change to handle a
value assigned to a Text data type field.

CurrentDb.Execute "Update tblDelayedOrders Set DELAYED = True Where
TRACKING = '" &
Me.txtOrderNumber & "';", dbfailonerror

Note the addition of the single quotes to delimit the value
Me.txtOrderNumber. Even though this may be a number, you are assigning it
to a text field and it will need to be treated as text. If the value can
have apostrophes in it, the syntax will need to be modified more.

--
Wayne Morgan
MS Access MVP
"N J" <bl*************@blueyonder.co.uk> wrote in message
news:VT*******************@fe3.news.blueyonder.co. uk...
Hi,

CurrentDb.Execute "Update tblDelayedOrders Set DELAYED = True Where ID =
" & Me.txtOrderNumber & ";", dbfailonerror
Me.StatusListBox.AddItem "ORDER # " & Me.txtOrderNumber & " MARKED AS
DELAYED " & "" & "", 0

When I change Where ID to Where TRACKING (another text field) I get the
error Data Type Mismatch in expression critera, or something like that

Help :(
ta

In addition to the comments you've already received, you also need to wary
of null values. In fact, I would take my time to dimension a strSQL
variable and build up the string before trying to execute it.

Dim strValue As String
Dim strSQL As String

strValue=Nz(Me.txtMyTextField ,"")

If Len(strSQL)>0 Then
strValue=AddQuotes(strValue, DoubleQuote)
strSQL="Update tblDelayedOrders Set DELAYED = True Where MyTextField=" &
strValue
...
Else
...
End If

And if adding those extra lines doesn't seem too bad you could also add
variables for dbs (Currentdb) so you can check for dbs.RecordsAffected,
which I gues should be one.
'Put the following in a separate module called modQuotes or similar:

Public Enum QuoteType
NoQuote
SingleQuote
DoubleQuote
End Enum

Public Function AddQuotes(strValue, Q As QuoteType) As String

Dim strReturn As String

Select Case Q

Case QuoteType.SingleQuote
strReturn = Replace(strValue, "'", "''")
strReturn = "'" & strReturn & "'"

Case QuoteType.DoubleQuote
strReturn = Replace(strValue, """", """""")
strReturn = """" & strReturn & """"

Case Else
strReturn = strValue

End Select

AddQuotes = strReturn

End Function





Nov 13 '05 #5

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

Similar topics

1
2477
by: LJgrnl | last post by:
I've got a type mismatch error that's driving me nutty. Variable blnNoData has the initial value False. If a recordset comes back empty (both .EOF and ..BOF are true) then blnNoData is set to...
1
4940
by: deko | last post by:
Okay, so I figured out how to pull Outlook Appointments into an Access Table (see below). But the data comes in the wrong Data Type - how do I convert it from Text to Long Integer? For...
2
10800
by: Chicken Kebab Abdullah | last post by:
Does anyone know why I get the error 3464 Data type mismatch from the following code. I have a form with a combo(to choose a consumable) and 2 list boxes on it. list on left is all printers...
0
2230
by: news.paradise.net.nz | last post by:
I have been developing access databases for over 5 years. I have a large database and I have struck this problem with it before but can find nothing in help or online. Access 2000 I have a query...
1
6526
by: ArcadeJr | last post by:
Good morning all! I have been getting a Run-time Error message #3464 - Data Type mismatch in criteria expression. While trying to run a query. I have a database where the field Asset_Number...
3
5593
by: Jake | last post by:
I am currently trying to create my own Point Of Sale software for my retail store. I wrote the program with the UPC field as Long integer. When I started to add the products by UPC code, I got a...
1
3269
by: amitbadgi | last post by:
I am getting the following error while converting an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Data type mismatch in criteria expression. ...
2
8967
by: psychomad | last post by:
Please, can someone help me out to solve this error, i've been searching throughout my codes and yet i didnt succeed in finding the error!!!! The Error is: Server Error in '/' Application....
15
7320
by: sara | last post by:
I have a Memo field in a table to hold notes from a conversation a social worker has had with a client (this is for a non-profit). If the user needs to update the memo field, I need to find the...
19
21529
by: Lysander | last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7120
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5050
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.