-----Original Message-----
I'm trying to make a calculated field based in the DLast
function but using a double criteria linked by the AND
operator, but the syntax has allways something wrong. Does
anyone have suggestions how to do it?
Thanks in advance.
PF
Ummm... tell us what you're doing. It's rather hard to say what you're
doing wrong given that you don't say what you're doing!
Just a few suggestions:
- The third argument to any Domain function should evaluate to a Text
String which would be a valid WHERE clause in a query. It's often
built up from pieces, but if you concatenate the pieces together it
should look like
[Thisfield] = 123 AND [thatfield] = 'SomeText'
- Numeric fields should have no delimiters; text fields must be
delimited using either ' or ". Using " is a bit tricky if you're
building up the string using string literals delimited by "; you may
need to use Chr(34) - the ASCII representation of " - such as:
DLast("[fieldname]", "[domain]", "[LastName] = " & Chr (34) &
strLastName & Chr(34))
in order to get a criterion
[LastName] = "O'Brien"
The ' in O'Brien would interfere if you used the singlequote
delimiter.
- VERY IMPORTANT: DLast() is just about USELESS. It returns the last
record *IN DISK STORAGE ORDER*, not the last record entered, not the
last record in the query's sort order. You have *no* control over
where Access will store records; DLast essentially (and expensively)
gets what amounts to a randomly chosen record from somewhere in its
domain. In other words... I don't think that you want to use DLast at
all! What are you trying to accomplish?
.