By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,833 Members | 2,076 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,833 IT Pros & Developers. It's quick & easy.

Compare part of 1 field with another field in access

P: n/a
Hi,

I am atempting to compare part of a field with the whole of another
field in access. Is this possible?

Basically I have 2 tables with the following info:

Table1
Field1 = MR.

Table2
Filed1 = MR

I want to be able to check whether the field in Table1 contains a
trailing fullstop, if it does i want ot remove it and then compare, if
it doesnt i simply want to compare to Table2 field.

Can this be done in the QBE window

Thanks

Nov 13 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
In the 18 hours between your first post on this subject and this re-post,
did you not have any success with the 2 suggestions which were kindly
offered by others? At least do those posters the courtesy of trying their
suggestions first.
Nov 13 '05 #2

P: n/a
Thank you for your lovely reply - surprisingly, I have already tried
the posts previous suggestions - but I will most certainly try again
now that you have nicely pointed this out!

Thank you once again for letting me know, ever so pleasantly - people
do make mistakes Mike, not everyone is as perfect and pedantic as you!!

Nov 13 '05 #3

P: n/a
<ge*********@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Thank you for your lovely reply
You're most welcome
- surprisingly, I have already tried
the posts previous suggestions
but it didn't work?
- but I will most certainly try again
now that you have nicely pointed this out!

Thank you once again for letting me know, ever so pleasantly
I'm glad you appreciate my pleasantness
- people
do make mistakes Mike, not everyone is as perfect and pedantic as you!!


You're too kind. Many people are a great deal more perfecter than me.
Nov 13 '05 #4

P: n/a
ge*********@hotmail.com wrote in news:1115799878.387838.171900
@o13g2000cwo.googlegroups.com:
Hi,

I am atempting to compare part of a field with the whole of another
field in access. Is this possible?

Basically I have 2 tables with the following info:

Table1
Field1 = MR.

Table2
Filed1 = MR

I want to be able to check whether the field in Table1 contains a
trailing fullstop, if it does i want ot remove it and then compare, if
it doesnt i simply want to compare to Table2 field.

Can this be done in the QBE window


Yes. This is a trivial problem but the solution depends upon information
you have not provided.

Are you using JET? If you don't know then answer is, "Yes".

Assuming "Yes":

Are you using a recent version of Access (>=2002 I believe) which will
allow you to use the VBA Replace function in queries? If not we may have to
write a UDF to remove the ".".

Must the "." stay in Table1, Field1, or may we just run an update query to
remove it and do our comparison later?

Are you comparing each of the rows in Table1 with each of the rows in
Table2?
If not how are you mapping the rows so that each row in Table1 is compared
with the appropriate row in Table2?

BTW. Two tables with the same data is almost always a bad idea. Just one of
the reasons is that it's difficult to keep the data in both tables up-to-
date.

--
Lyle

"The aim of those who try to control thought is always the same. They find
one single explanation of the world, one system of thought and action that
will (they believe) cover everything; and then they try to impose that on
all thinking people."
- Gilbert Highet
Nov 13 '05 #5

P: n/a

Mike MacSween wrote:
<ge*********@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Thank you for your lovely reply
You're most welcome
- surprisingly, I have already tried
the posts previous suggestions


but it didn't work?
- but I will most certainly try again
now that you have nicely pointed this out!

Thank you once again for letting me know, ever so pleasantly


I'm glad you appreciate my pleasantness
- people
do make mistakes Mike, not everyone is as perfect and pedantic as

you!!
You're too kind. Many people are a great deal more perfecter than me.


Bless! Learn to spell!!

Nov 13 '05 #6

P: n/a
Yes, using JET (cos i didnt know the answer)

Unfortunatley, I am using Access 2000 so I cannot use the Replace
function.

We can use an update query to remove the "." and compare later as the
dot does not have to remain in Table1 (if present at all not all
records contain a dot - 80% records have trailing dot)
Idealy I'd like to remove the dot and then compare (as if the dot was
never there)

Linking the tables via another field - NINO (primary key)

The 2 tables do not have the exact same fields (similar tho) I am
trying to compare other fields as well as TITLE for Data Integrity
reasons - I've imported the files into Access

Thankyou

Nov 13 '05 #7

P: n/a
I can't see the rest of this thread, so I don't know everything that's
transpired so far, but you can use Replace in Access 2000. If you haven't
applied all of the service packs, you may have to write your own function
that calls Replace and use it instead. Something like:

Function MyReplace(Expression As String, _
Find As String, _
Replace As String, _
Optional Start As Long = 1, _
Optional Count As Long = -1, _
Optional Compare As Long = 0) As String

MyReplace = Replace(Expression, Find, Replace, _
Start, Count, Compare)

End Function

If you know you're not going to be using the Start, Count or Compare
parameters, you can leave them out.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

<ge*********@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Yes, using JET (cos i didnt know the answer)

Unfortunatley, I am using Access 2000 so I cannot use the Replace
function.

We can use an update query to remove the "." and compare later as the
dot does not have to remain in Table1 (if present at all not all
records contain a dot - 80% records have trailing dot)
Idealy I'd like to remove the dot and then compare (as if the dot was
never there)

Linking the tables via another field - NINO (primary key)

The 2 tables do not have the exact same fields (similar tho) I am
trying to compare other fields as well as TITLE for Data Integrity
reasons - I've imported the files into Access

Thankyou

Nov 13 '05 #8

P: n/a
ge*********@hotmail.com wrote:
Yes, using JET (cos i didnt know the answer)

Unfortunatley, I am using Access 2000 so I cannot use the Replace
function.

We can use an update query to remove the "." and compare later as the
dot does not have to remain in Table1 (if present at all not all
records contain a dot - 80% records have trailing dot)
Idealy I'd like to remove the dot and then compare (as if the dot was
never there)

Linking the tables via another field - NINO (primary key)

The 2 tables do not have the exact same fields (similar tho) I am
trying to compare other fields as well as TITLE for Data Integrity
reasons - I've imported the files into Access

Thankyou


In Access 2000, I believe we can use the replace function in a wrapper,
SQLRemove, as below.
I ran the function RemoveThePeriods successfully.

<warning style="color:red;font-size:x-large;font-weight:bold">

1. I have not removed the reference to ADO;
2. I created a safety copy of my table first;
3. I used names for the table and fields which are match the table I
want to modify.
4. I checked the code to remove any extraneous line breaks my newsreader
might have inserted.

</warning>

Public Function SQLRemove(ByVal vName As String, ByVal vChar As String)
As String
SQLRemove = Replace(vName, vChar, "")
End Function

Public Function RemoveThePeriods()
CurrentProject.Connection.Execute ("UPDATE Schools SET SchoolName =
SQLRemove(SchoolName,""."")")
End Function

--
--
Lyle

"The aim of those who try to control thought is always the same. They
find one single explanation of the world, one system of thought and
action that will (they believe) cover everything; and then they try to
impose that on all thinking people."
- Gilbert Highet
Nov 13 '05 #9

P: n/a
Brilliant - many thanks!

Nov 13 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.