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

Help with lookup

Hi everybody,

I'm very new to access so please treat me with kid gloves! (i'm
hopeless with code and macros but enjoying learning). I am loving what
it is capable of though, and i'm sure I haven't scratched the surface.
I have a beginners book & have read many posts, and help files but i am
still stuck.

I am looking to use the equivalent of a Vlookup function from excel,
however I am sure there will be a better way to do this.

I have 2 tables [customers] and [petals].
[Customers] contains fields called [postcode] and [petal number]
[Petals] also contains fields called [postcode] and [petal number]

In the [petals] table each different postcode entered has a
corresponding petal number (1 - 6). So numerous different postcodes
apply to each petal no.

When the postcode is entered in the [customers] table I would lke the
[petal number] field to automatically lookup the value from the
[petals] table for the corresponding postcode.

I hope i have explained this well enough for everone to understand. If
I could just be pointed n the right direction that would be fantastic.
( know in this example it appears like I am repeating data in two
tables but it makes sense (to me at least).

Thanks in advance for any help you can give.

Nov 30 '06 #1
4 1337

I have also just read about a function called autolookup - perhaps this
is what need to use. However following the instructions to create the
autolookup query doesn't work.

Nov 30 '06 #2
keri wrote:
Hi everybody,

I'm very new to access so please treat me with kid gloves! (i'm
hopeless with code and macros but enjoying learning). I am loving what
it is capable of though, and i'm sure I haven't scratched the surface.
I have a beginners book & have read many posts, and help files but i am
still stuck.

I am looking to use the equivalent of a Vlookup function from excel,
however I am sure there will be a better way to do this.

I have 2 tables [customers] and [petals].
[Customers] contains fields called [postcode] and [petal number]
[Petals] also contains fields called [postcode] and [petal number]

In the [petals] table each different postcode entered has a
corresponding petal number (1 - 6). So numerous different postcodes
apply to each petal no.

When the postcode is entered in the [customers] table I would lke the
[petal number] field to automatically lookup the value from the
[petals] table for the corresponding postcode.

I hope i have explained this well enough for everone to understand. If
I could just be pointed n the right direction that would be fantastic.
( know in this example it appears like I am repeating data in two
tables but it makes sense (to me at least).

Thanks in advance for any help you can give.
I'm not sure exactly what you are asking for. In customers you have a
zip code field. When you are on a customer record, you want to see
related records in the petal table. There is one record in customer and
there are 0 to Many (6) in the petal table. Is this correct?

You could create a form/subform. First, create a form for customers.
Make it a Single Form; only 1 customer for the form.

Next, create a form containing the data from Petals you want to display.
This could be a continuous form or a data sheet or a single record
form, your choice.

Now open the main form for customer in design mode. On the toolbar
(hammer/pick icon) select the subform control and place it on the form.
Link the two forms via the ZipCode field (you can see the link in the
property sheet for the Petals subform).

Now save and run.
Nov 30 '06 #3
Sorry, I knew I had explained this very badly. I'll try again.

Basically every post code will be assigned a "petal number" (a category
number from 1-6). This will be done via a form. Imagine post code AB1
was assigned petal number 2 and NN4 was assigned petal number 5.
When I enter data (through a form) into the customer table, if I enter
"AB1" into the post code field I want the "petal number" field to
automatically show 2 or if i entered NN4 into the post code field the
"petal number" would show 5.

I have tried numerous queries and relationships but i really don't know
what I am doing. I hope this explanation is clearer.

Thanks.

Nov 30 '06 #4
keri wrote:
Sorry, I knew I had explained this very badly. I'll try again.

Basically every post code will be assigned a "petal number" (a category
number from 1-6). This will be done via a form. Imagine post code AB1
was assigned petal number 2 and NN4 was assigned petal number 5.
When I enter data (through a form) into the customer table, if I enter
"AB1" into the post code field I want the "petal number" field to
automatically show 2 or if i entered NN4 into the post code field the
"petal number" would show 5.

I have tried numerous queries and relationships but i really don't know
what I am doing. I hope this explanation is clearer.

Thanks.
2 methods I'll relate. I'll assume zipcode is text, not numeric, so
I'll surround in single quotes. Assume your formname is called
FormName, the Petal field is called Petal.

=Dlookup("PetalNum","PetalTable","ZipCode = '" & Me.ZipCode & "'")

In the Petals control source you'd stick that Dlookup. It won't be
editable. In the ZipCode AfterUpdate event enter
Me.Petal.Requery
You requery in case an update is made. This will return ONE value.

If you have multiple values, you might create a combobox/listbox with
the Rowsource being something like
Select PetalNum From PetalTable WHere ZipCode = '" & _
Forms!FormName!ZipCode & "'"

In this case, this will select all petals with the zip code for the
customer you are looking at.

In the AfterUpdate event of the zipcode enter
Me.ComboBoxNameOrListBoxName.Requery

If this doesn't help, respond back.
Dec 1 '06 #5

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

Similar topics

4
by: Adrian Charteris | last post by:
Hi I'm currently trying to use a lookup table for converting one xml doc to another using a XSLT transformation. Ideally I would like my first xml doc to be converted to my second xml doc below. ...
3
by: Julius Mong | last post by:
Hi all, I'm doing this: // Test char code wchar_t lookup = {0x8364, 0x5543, 0x3432, 0xabcd, 0xef01}; for (int x=0; x<5; x++) { wchar_t * string = (wchar_t*) malloc(sizeof(wchar_t)); string =...
1
by: James E | last post by:
I have a question about best practices of how to deal with lookup data from my C# apps. On a couple of occasions I have come across a problem where I have to automate inserting a record into a...
1
by: Sophie Bradshaw | last post by:
i was wondering if anyone could possibly help me! i have a ms access database, and in one of the tables, one of the fields is a lookup column, with several possible values. what i want to do is...
20
by: Jack Schitt | last post by:
I thought I was starting to get a handle on Access, until I tried doing something useful...now I'm stuck. I have a DB with two tables - to keep it simple I'll say that one is an Employee File...
28
by: Bailey.W87 | last post by:
my professor give me this assignment. Sort the R's B's and W's in an array. for example, the user enter: R B W W B B R W W R R W R B W i need to swap the characters in the array and arrange it...
4
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
1
by: aharding | last post by:
Hello! I am using Access 2003 I have been playing with DLookup all morning and have not been successful yet. I have never used this function...and have some limited experience with code. I...
2
by: Richard | last post by:
Help please. I am trying to autofill a form text field from a select-box lookup. I have no problem doing this if the select-box is part of the form but because there are 5 possible select boxes...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.