AND criteria in DLast funtion

  • Thread starter Thread starter PF
  • Start date Start date
P

PF

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
 
I would caution against using DLast() but your experience may vary.
Can you provide any information regarding field and table names as well as
your criteria. I doubt anyone is willing to take a WAG with so little to go
on.
 
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?
 
Ok; I'm trying to make a database of published daily taxes
(%). The problem is that in weekends, hollydays, etc.
there are no tax published, so I want to the tax in any
one of this days to assume the value of the last published
tax.
I have a table with these fields: date-[Dt]; value of tax-
[Tx]. Note that in hollydays, etc. the field [Tx] is empty.
I managed to make it assume the day before, but if I have
two or more consecutive days without tax, it gives me a
wrong value.

Thanks in advance.

PF

PS: I had no idea that DLast (and I assume that DFirst and
the rest of these functions) were so uncertain.
-----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?


.
 
Try looking at the DMax()function. From what you have
described it looks like you could use this to look up the
max date where tax > 0.
 
Ok; I'm trying to make a database of published daily taxes
(%). The problem is that in weekends, hollydays, etc.
there are no tax published, so I want to the tax in any
one of this days to assume the value of the last published
tax.
I have a table with these fields: date-[Dt]; value of tax-
[Tx]. Note that in hollydays, etc. the field [Tx] is empty.
I managed to make it assume the day before, but if I have
two or more consecutive days without tax, it gives me a
wrong value.

See Tom Ellison's excellent suggestions in the thread "Please help
with aggregate functions!" in this newsgroup (you can go to
http://groups.google.com and use Advanced Search if your newsreader
doesn't show the thread).
 
Back
Top