You are missing the delimiting double quotes:
MaxMileage: DMax("[EndingMileage]","[Trip]","[TagNumber] = """ & [TagNumber]
& """" )
It may be easier to figure it out from the error message, since the right
expression, once printed, should have been:
'[TagNumber] = "A10-4741F" '
instead of the actual
'[TagNumber] = A10-4741F'
See, the double quotes which EXPLICITLY 'limits' the string content, else,
it is read as variable A10 from which we subtract 4741f (whatever 4741f
could be) and the computer gave up, trying to understand. To add the
delimiter, a double quote, we need to DOUBLE it, since it is already inside
a string:
ThisIsStringWithAspaceAQuoteAndASpace= " "" "
ThisIsStringWithSomeTextAQuoteAndASpace= "SomeText "" "
or " [TagNumber]= "" "
So the proposed syntax:
" [TagNumber]= "" " & fieldName & " "" "
where you need to remove a couple of space, since you want something like:
"A10-4741F"
not
" A10-4741F "
Vanderghast, Access MVP
Donna said:
I have a database where, among other things, I need to calculate mileage.
I
used your below example and substituted [EndingMileage] for
[DateFieldName],
[Trip] for [contactedTableName] and [TagNumber] for [CustNum] which looks
like this:
MaxMileage: DMax("[EndingMileage]","[Trip]","[TagNumber] = " &
[TagNumber])
Vehicle table name is [Vehicle] where [TagNumber] resides
Mileage/trip table name is [Trip] where [Ending mileage]s and [TagNumber]s
are stored
When I run the above query I get this error statement:
"Syntax error (missing operator) in query expression '[TagNumber] =
A10-4741F'
What am I doing wrong and is there a template for calculating mileage?
Thanks.
--
Donna N.
Ofer said:
Use Dmax in the query.
Create a NewField in the query and write
MaxDate: DMax("[DateFieldName]","[contactedTableName]","[CustNum] = " &
[CustNum])
=======================
In SQL it will look like
Select [CustNum],
DMax("[DateFieldName]","[contactedTableName]","[CustNum] =
" & [CustNum]) As MaxDate From TableName
--
\\// Live Long and Prosper \\//
BS"D
:
I have 2 tables in Access, one holds Clients Initial Details, the other
holds
a record of each time they are contacted, how can i pull the most
recent
contact date for each Client? HELP PLEASE.