473,320 Members | 2,112 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,320 software developers and data experts.

How to cross-reference using a lookup field/table?

greeni91
I am currently in the process of creating a database to record problems at my work.

I am trying to AutoFill a field (Material Type) if another field (Material) has a number exactly like the primary key in my lookup table. e.g. If I input the number "6046" in the Material field I want it to populate the Material Type field with "Stainless Steel".

I have setup my lookup table with the number relating to the material type as the primary key... This is a Rolls Royce code which is an MSRR number relating to a specific material.

I was wondering if anyone could help, I have tried several methods to no avail, some even causing referential damage to the database.

Any help is greatly appreciated.

/Sandy
Mar 4 '10 #1

✓ answered by missinglinq

If Material is defined as a Number Datatype:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Material_AfterUpdate()
  2.  Me.MaterialType = DLookup("MaterialType", "MaterialTableName", "[Material] = " & Me.Material)
  3. End Sub
If it's defined as Text:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Material_AfterUpdate()
  2.  Me.MaterialType = DLookup("MaterialType", "MaterialTableName", "[Material] = '" & Me.Material & "'")
  3. End Sub
Linq ;0)>

3 2822
missinglinq
3,532 Expert 2GB
If Material is defined as a Number Datatype:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Material_AfterUpdate()
  2.  Me.MaterialType = DLookup("MaterialType", "MaterialTableName", "[Material] = " & Me.Material)
  3. End Sub
If it's defined as Text:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Material_AfterUpdate()
  2.  Me.MaterialType = DLookup("MaterialType", "MaterialTableName", "[Material] = '" & Me.Material & "'")
  3. End Sub
Linq ;0)>
Mar 4 '10 #2
NeoPa
32,556 Expert Mod 16PB
If you are truly talking about a field and not a control then I recommend you do not store it separately at all. This is related to the very basics of Normalisation. See Normalisation and Table structures.
Mar 4 '10 #3
Thanks Missinglinq,

I used your code for Material defined as a number and changed the MaterialTableName and it worked no bother...
Mar 8 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Web Master | last post by:
Are there any good websites or books that deal with cross platform XML? I'd like to target Internet Explorer/Netscape Navigator 5 or later, as well as Opera, possibly konqueror on Linux as well. ...
12
by: * ProteanThread * | last post by:
but depends upon the clique: ...
23
by: Jeff Rodriguez | last post by:
Here's what I want do: Have a main daemon which starts up several threads in a Boss-Queue structure. From those threads, I want them all to sit and watch a queue. Once an entry goes into the...
7
by: Efrain Marrero | last post by:
i want to now how to do this in python this is java for(int i=1 ; i<=lim ; i++){ for(int j=i+1; j<=lim+1; j++){ for(int k =j+1; k<=lim+2;k++){
3
by: aspmonger | last post by:
Hello, I really believe that IE 6 has a new (intentional?) bug that severely limits the capability of dhtml and cross domain scripting. Yesterday, I read an interesting article about the subject and...
6
by: Robert Bravery | last post by:
Hi all, Can some one show me how to achieve a cross product of arrays. So that if I had two arrays (could be any number) with three elements in each (once again could be any number) I would get:...
1
by: Han-Wen Nienhuys | last post by:
Hello, I have a small patch for Python SVN that makes it possible to cross-compile python on Unix to various other Unix targets. I have successfully built a binary for FreeBSD on Linux. The...
5
by: Spam Catcher | last post by:
Hello Everyone, I need to implement single sign on across serveral applications. Some applications are under my control while others are under the control of 3rd parties. Can anyone suggest a...
3
by: Squat'n Dive | last post by:
Does anyone have an idea why -fno-strict-aliasing is turned off when cross compiling? in configure generated for 2.4.4: case $GCC in yes) # Python violates C99 rules, by casting between...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.