473,395 Members | 1,341 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,395 software developers and data experts.

lookup query?

Hi this seems like a very simple thing to do but I am having no
success.

What I want to do is compare a value from a calculated field with a
value from a table and then if it is in the table display another field
in the table associated with it.

ie I have a table of postcode 'starts' and a corresponding area ID
code. I have a calculated field in a query that strips off the first
two (or one) letter from the postcode. How do I say 'compare this with
the table and give me the resulting area code'?

Thanks DD

Nov 13 '05 #1
6 4697
Rog
Just create a new query linking your table and your query on the
"postcode start" - or am I missing something?

Nov 13 '05 #2
Hi

I have tried that and I get 'data type mismatch in criteria
expression'. I have created a query with my table and postcode start
query and linked the postcode field (which is a list of possible
abreviated codes) with the postcode start calculation (which is a list
of actual abreviated codes). I have a feeling I am so close! Many
thanks for the help
DD

Rog wrote:
Just create a new query linking your table and your query on the
"postcode start" - or am I missing something?


Nov 13 '05 #3
Rog
Make sure the fields you link have the same type. For instance, if the
PostCodeStart field in your table is numeric (long), you can force the
calculated field in the query to have the same type by using CLng(...)

Nov 13 '05 #4
I think I have worked it out. There are missing postcodes in my table
and out of 10000 records I have 25 '#error' results. So I will need to
find a way to add to the code to see if I can eliminate errors. Any
ideas? The code I am using is this:
Function StripPC(PostalCode As String) As String

If Len(PostalCode) >= 2 And Mid(PostalCode, 2, 1) < "a" Then
StripPC = Left(PostalCode, 1)

Else

StripPC = Left(PostalCode, 2)
End If

End Function

many thanks for your help
DD
Rog wrote:
Make sure the fields you link have the same type. For instance, if the PostCodeStart field in your table is numeric (long), you can force the calculated field in the query to have the same type by using

CLng(...)

Nov 13 '05 #5
Rog
change your function line to:

Function StripPC(PostalCode)

so that it will not only accept strings, and start the code with

If IsNull(PostalCode) then
StripPC = null
ElseIf Len(PostalCode) etc.

Nov 13 '05 #6
Many thanks Rog that seems to have done the trick! Finally!
DD

Rog wrote:
change your function line to:

Function StripPC(PostalCode)

so that it will not only accept strings, and start the code with

If IsNull(PostalCode) then
StripPC = null
ElseIf Len(PostalCode) etc.


Nov 13 '05 #7

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

Similar topics

3
by: my-wings | last post by:
I've been reading about how evil Lookup fields in tables are, but I've got to be missing something really basic. I know this subject has been covered before, because I've just spent an hour or two...
1
by: Zachary Turner | last post by:
I want to make a Lookup Field based on another Lookup field. In other words, I have this table A with two fields: ID and Name, where ID is an Autonumber and Name is a friendly name. Then I have a...
3
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems...
1
by: Robert | last post by:
I am trying to create a db for service providers by county. I'm relatively new to db programming, but I have done quite a bit of programming ranging from the old basic days up to doing some...
7
by: Juris Krumins | last post by:
I have a problem with postgresql tables. periodicaly, I would say frequently about 5-10 time per hour i have such errors in my server log file: 2004-04-14 12:23:32 ERROR: cache lookup of...
5
by: Kevin | last post by:
I was reading on the mvps.org site not to use the lookup wizard in the table design, but rather use a query. I'm confused by this, given that the lookup wizard basically creates a query and uses...
9
by: linda | last post by:
I have a form with some combo boxes used as lookup fields: customer Name, Customer Number, Address, Phone number. I have imported the customer information form another data base. The lookup...
2
by: Greg Strong | last post by:
Hello All, Is it possible to change table field lookup properties in code? I've been able to change other field properties in code, however so far no luck with field lookup properties. What...
1
by: hawk7890 | last post by:
I created an access database using access 2003 with lookup tables and I am having isues where my combo boxes on the form update the lookup table instead of the master table. I have a query to my...
1
by: joeino | last post by:
I want to do a lookup query and append the record to a history table before editing the data. I created a macro to run the lookup query to append the record to history and it works fine. I did the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.