Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / January 2006

Tip: Looking for answers? Try searching our database.

Data type mismatch in query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mjj4golf - 11 Jan 2006 13:31 GMT
I have an update query that uses criteria in the id field.  It is a long
variable set in one of the forms and is called DeleteID.  In the query I set
the criteria field to:
=DeleteID but it changes it to "DeleteID".  I run the query from the form
and get a 'data type mismatch'.

Mike J
Cinzia - 11 Jan 2006 13:53 GMT
> I have an update query that uses criteria in the id field.  It is a long
> variable set in one of the forms and is called DeleteID.  In the query I set
> the criteria field to:
> =DeleteID but it changes it to "DeleteID".  I run the query from the form
> and get a 'data type mismatch'.

Hi Mike,
you can't use a variable in a query criteria.
This is a Workaround:
Make a function in a module like this:

public Function GetDeleteID() as Long
       GetDeleteID=DeleteID
end Function

In the query use the Function GeteDeleteID() instead of DeleteID

UPDATE  YourTable Set FieldX=YYYY  Where ID = GetDeleteID()

Cinzia
John Spencer - 11 Jan 2006 13:55 GMT
Enter the criteria with brackets around the item, so Access will know you
are referring to a field.

Criteria: =[DeleteID]

To be extra safe
Criteria: =[Your Table Name with DeleteID in it].[DeleteID]

>I have an update query that uses criteria in the id field.  It is a long
> variable set in one of the forms and is called DeleteID.  In the query I
[quoted text clipped - 4 lines]
>
> Mike J
Ofer - 11 Jan 2006 14:00 GMT
If the criteria for the query is a field in the form, you should use

Forms![FormName]![DeleteID]
=============================
The thing that pazzle me, if the query change automatically to "DeleteID" it
mean that the field type is string, and you said that the field type is
number.

Signature

\\// Live Long and Prosper \\//

> I have an update query that uses criteria in the id field.  It is a long
> variable set in one of the forms and is called DeleteID.  In the query I set
[quoted text clipped - 3 lines]
>
> Mike J
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.