473,473 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Run-time error '3464' - Data type mismatch in criteria expresssion

6 New Member
So...I'm trying to create a field that automatically calculates a value by gathering data from multiple tables.

My code seems to be fine, but MS Access returns with an error:

Run-time error '3464' - Data type mismatch in criteria expresssion

My code is as following:
Expand|Select|Wrap|Line Numbers
  1. Dim AccommodationType As String
  2.  
  3. AccommodationType = DLookup("AccommodationType", "Accommodations", "AccommodationID = '" & Me.Accommodation.Value & "'")
For your reference:

1. The error occurs on the second line of the code (DLookup)
2. The data type for the field: "AccommodationType" is Number
3. The data type for the field: "AccommodationID" is Number
4. The data type for the field: "Me.Accommodation.Value" is Number

Any ideas?
Dec 2 '15 #1
2 4252
mbizup
80 New Member
Delimiters...

Text uses quotes
Dates use hash marks (#)
Numbers - no delimiters

so your syntax should be (drop the single quotes since AccommodationID is a numeric field):
Expand|Select|Wrap|Line Numbers
  1. AccommodationType = DLookup("AccommodationType", "Accommodations", "AccommodationID = " & Me.Accommodation.Value) 
Dec 2 '15 #2
zmbd
5,501 Recognized Expert Moderator Expert
You might want to consider building your strings first too:

So:
Expand|Select|Wrap|Line Numbers
  1. Dim AccommodationType As String
  2.  
  3. AccommodationType = DLookup("AccommodationType", "Accommodations", "AccommodationID = '" & Me.Accommodation.Value & "'")
goes to:

Expand|Select|Wrap|Line Numbers
  1. Dim zCondition as string
  2. '
  3. zCondition = "AccommodationID = '" & _
  4.     Me.Accommodation.Value & "'"
  5. '
  6. 'Debug.Print "zCondition = " & zCondition 'uncomment to debug
  7. '
  8. DLookup("AccommodationType", _
  9.     "Accommodations", _
  10.      zCondition)
Most Dlookup errors occur from a malformed conditional string which is difficult to troubleshoot when built witin the function.

-z
Dec 3 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
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
by: John Smith | last post by:
Hi I am getting the above error when I try to run the union query shown below select all as , as , as , as , ,, ,, , , as , as , as , as , as from
1
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...
2
by: technocraze | last post by:
Hi guys, Implementations application & programming environ MS Acess + Visual Basic Table fields Serialno (pk) - Auto number StudentId - text Course - text intake - number
2
by: tiiim | last post by:
hi all i created two textboxes to insert date and a button..i hv this following code for that button..but when i ran error msg shows error like 'runtime error 13' & type mismatch..i hv no idea...
1
by: Bamboz | last post by:
Dears, I have a table named Tasks that Contains all the Information about my employee , i am making a Form to open a report based on Employee Name, Tasks done, Date. but i'm getting error with this...
4
by: shalskedar | last post by:
I want to transfer the excel data to th Db ..thru the VBA code. In the DB there is a table called outer2 containing 1 of the columns as "Upvc" whose format is set to Long integer. When i try to...
7
by: Vasago | last post by:
Trying to look up a value based on 2 criteria. Can't seem to debug the error thanks for your help! = Nz(DLookup("", "", "Employee='" & Forms!! & "And ='" & Date & "'"), 0)
3
by: Logan Cortes | last post by:
Good day, I'm having the error in the following code: dtaactcong.RecordSource = "select Cedula_Congregado, Cancelado from Congregados_Actividades where Codigo_Actividad =" & txtcodact.Text ...
3
by: laht0028 | last post by:
Hello, I'm attempting to use a combo box to search a list in a subform. I have the following code but when I attempt to use the combo box I get and error (Error 3464 in setting subform filter:...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.