473,372 Members | 1,234 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

Compare part of 1 field with another field in access

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
9 5567
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
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
<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
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

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
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
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
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
Brilliant - many thanks!

Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Simon Gare | last post by:
Hi I need to compare a dynamic field in an asp page to a field in another table, if there is no match then i would like to chane the row colour ( see code below). The problem Im having is...
5
by: Megan | last post by:
Hi everybody- I'm helping a friend with a music database. She has an old one and is creating a new one. She wants to compare records and fields in the old database with records and fields in the...
2
by: Megan | last post by:
Hi everybody- I have 2 tables, Hearings and Rulings. Both have primary keys called, CaseID, that are autonumbers. I don't want both tables to have the same autonumber. For example, if Hearings...
3
by: ChadDiesel | last post by:
Hello everyone. I need some advice on table structure for a new project I've been given. One of our customers sends us an Excel spreadsheet each week containing their order. Currently, someone...
6
by: geronimo_me | last post by:
Hi, I'm trying to compare two TITLE fields from different tables to locate anomolies - however Table1 TITLE field contains a dot(.) after some of the entries, however i want to remove the dot so...
5
by: Edd E | last post by:
Hi, I have a database to store my analyses (Access 2002, WinXp), the basic structure is: TABLE 1 = Sample Info TABLE 2 = Analysis type 1 TABLE 3 = Analysis type 2 TABLE 4 = Analysis type 3 ...
1
by: olle | last post by:
hi I have a real problems with comparering date in asp and sqlserver In sqlserver I have a table tblDates with the field dtmDate the field dtmDate in a sqlserver table may contain a date like...
6
by: napatel04 | last post by:
Hi everyone, I would like to know if there is a quick query someone can help me write for the following scenario. I think I can do this with VBA but since this is suppose to be a temp. solution,...
0
by: Tony Hine | last post by:
Problem for Excel Developers One of the problems facing Excel developers moving into MS Access is actually the apparent similarity between MS Access tables and Excel spreadsheets. MS Access is...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.