On Feb 29, 3:55 pm, "Conan Kelly"
On Feb 29, 2:47 pm, "Conan Kelly"
On Feb 29, 1:11 pm, "Conan Kelly"
Chu Gai,
I would definately parse this field out into 3 separate fields.
Create a
query that will do this and save this query. Then you can create
another
query based off of this query that will be easier to work with.
Something
like this might help:
SELECT Left([TableName].[FieldName],2) as PersonsInitials,
DateValue(Mid(Left([TableName].[FieldName],3,InStr([TableName].[FieldName],"#")))
as SentDate,
Right([TableName].[FieldName],Len([TableName].[FieldName])-InStr([TableName].[FieldName],"#"))
as NumberSent
FROM [TableName]
Be sure to chang "TableName" and "FieldName" appropriately. You can
add
any
other fields that you need to the query as well.
I have not tested this. I've typed it in to my response from memory,
so
there is a chance for typos or incorrect use of functions. Let me
know
how
it works out, and I can tweak it for you if it gives you trouble..
HTH,
Conan
One of the fields in a query has an alphanumeric term that looks
like
this...
sb1/02/08#5
The first two characters represent the initials of the person who
sent
the email. Different people have different intials but it's always
two
characters.
The part in the middle that looks like a date is the date the
email
was sent.
The #5, which could be #anynumber represents whether it was the
first,
second, tenth, whatever email that was sent.
What I'd like to be able to do is to be able to pull the records
for
the past two weeks starting from the current day. Kind of like
Date()-15. However, I'm striking out with figuring out how I can
use
both wildcards along with a calculated date range.
I know this is ugly and maybe the data ought to be parsed into
three
fields that could be concatenated after the fact, but this is the
way
it's going to be for now. Any idea how to write the criteria
expression?- Hide quoted text -
- Show quoted text -
Well, I'll tell you what I did (BTW, I'm most definitely pretty
inexperienced in Access and just helping out the little lady here).
I
wrote an expressions that looks like this...
Expr5: Format(Mid([CCC Control no],3,InStr(1,[CCC Control
No],"#")-3),"mm/dd/yyyy")
Now, this works fine with respect to pulling the date out of the
field. However, this then becomes my problem. I can't filter the
result to get data for the past two weeks like by >Date()-14. What I
get is a INVALID PROCEDURE CALL, the query comes up with #Names?..
Got
an idea here?
Chu Gai,
If I remember correctly, the Format() function returns a string, so
you
are
trying to filter text using a date. Try this:
Expr5: DateValue(Mid([CCC Control no],3,InStr(1,[CCC Control
No],"#")-3))
That should convert it to an actual date, then your filtering method
might
work.
Let me know how it works out.
HTH,
Conan- Hide quoted text -
- Show quoted text -
Well Conan, turns out the thing I wrote worked (your initial thoughts
reminded this dunderhead about the Instr function which led me to what
I posted above) AFTER I corrected a few typos that I found. I quite
agree with you about parsing the data into three fields, but at this
time, that just ain't gonna happen.
You've been enormously helpful Conan. Perhaps I can impose on you once
more. In a table, this particular field is called [CCC Control No].. No
brackets of course. Can you help me, based on my first post, with
setting a validation rule that's commensurate with the way data would
be entered?
Chu Gai,
Can you help me, based on my first post, with
setting a validation rule that's commensurate with the way data would
be entered?
YOU MEAN PEOPLE ARE ENTERING DATA THIS WAY!!! This is not coming from
some
other system/application?!?!?!?! No offense, but this is a BAD design
(please forgive me if it is yours). This table is storing 3 different
fields that should be 3 different data types in one field.
I strongly urge you to change this, but I guess I can understand,
especially
if there are alot of queries/reports/forms that depend on this field..
I'm not too sure about a validation rule, but how about an input mask?
Maybe something like this:
<LL#0/00/00\#09;0;_
I'm not too sure about the first pound/number sign (#). Help says "Digit
or
space (entry not required; spaces are displayed as blanks while in Edit
mode, but blanks are removed when data is saved; plus and minus signs
allowed).", but I can't tell if the space is being removed. It looks
like
it is still there after the record is saved. NEVER MIND!!! I just tried
it. If I actually enter a space, that is the same as entering a digit so
it
stores the space. If I skip over this character with the arrow key, then
the space is removed.
This input mask will allow for 1 digit months, 2 digit days, and 2 digit
years (if your dates are in the US format of m/dd/yy). Also you won't
have
to enter the date slashes or the pound sign, but it will store those
characters in the data.
If you want to require 2 digit months, then change it to:
<LL00/00/00\#09;0;_
Look up Input Mask in the Help for all of the details/codes that canbe
used.
I'm don't think Validation Rule uses all of the same codes. I don't know
if
you could come up with a validation rule that will do the same thing..
HTH,
Conan- Hide quoted text -
- Show quoted text -
It's not mine Conan. There's a department that my wife has to deal
with and the way that department does things trumps matters and sets
the tone. Nothing that can be done about it. That's where it comes
from. Like I said, when I saw it, my thoughts echoed yours with
regards to three separate fields. This may still be implemented on her
end but right now, there's a lot of historical data to deal with.
I'll try your suggestion. Thanks again
- Hide quoted text -
- Show quoted text -
OK, I went with your method of representing the date since it sorts
correctly while mine...well it doesn't
However, if I then type into the criteria that I want to see dates
later than a particular time like this...
#2/1/2008# or >Date()-14 (I'm assuming that means for the past 2 weeks),
then what I get is a message that says, "Date Type Mismatch in Criteria
Expression". OK, got a fix > > my new found friend?