473,804 Members | 2,123 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1360

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("Petal Num","PetalTabl e","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.Requer y
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.ComboBoxName OrListBoxName.R equery

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
4305
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. All that I want is to replace node names with a matching value in the lookup table and place the result into an field attribute pair: Example: id to be renamed instrument_id thus <id type="master">asset #132</id> becomes <field...
3
2987
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 = (wchar_t*)lookup; string = '\0'; CComBSTR bstrTest = SysAllocString(string); }
1
3107
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 table that has a foreign key constraint that is linked to a lookup table. E.g. Take the following database structure: SQL-Server Database: Table 1:
1
3576
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 when i create a record and choose a value for the lookup, i want the next record to default to the value in the previous record in the lookup field. e.g. if record 1 has 'example' as the value for the lookup field, record 2, when tabbed into it...
20
2386
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 (Employees), and the other is an Address File (Addresses) linked by SSN. I've set Addresses as a Lookup Table - If the user starts typing in the SSN it should pull up the Employees records. I'm getting stuck in the Data Entry form. When I type in...
28
2204
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 into R R R R R W W W W W W B B B B --------------------------------------------------------------------
4
4623
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 bound to a table as a lookup, drawing values from another table to populate the available selections. This all worked fine in VB6. I have distilled the problem down to a simple form drawing data from the Northwind database for a representative...
1
1807
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 will post what I have tried so far and hopefully someone can help me problem solve. I have tried three different methods... (I know Calculation is spelled wrong..I have to go through my database and fix it everywhere just haven't had the time...
2
2600
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 for them to choose from and because of the very large number of options in each select box, to save form loading time, I want to put the look-up select boxes on separate (pop-up) pages. (I prefer them not to be hidden divs on the same page) ...
1
2293
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 same with the lookup query that allows the user to edit the record. I then converted them to vb and combined them. Code follows. My thinking is to create a variable dim keyno longint then pass keyno to the lookup queries. I am kind of new...
0
9715
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10352
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10097
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9175
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5535
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3835
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.