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