Dlookup from 2 tables

rplohocky

Active Member
Joined
Sep 25, 2005
Messages
292
Office Version
  1. 365
Platform
  1. Windows
Hello,
I have a large unbound text box on a basic form. I am trying to use that box for instructions based on what appears in another field on the form. For example when field [ERROR] displays "ADDRESS TO FOLLOW", I would like to have the text box display how to correct the problem. Each day I get en error report and have to upload a new spreadsheet into access. Each day we have to go into our system and fix these errors that are generated by our system. I am trying to make it easier to understand how to fix the error by having a large text box display the action they need to take to fix the problem. So as you filp through each record a different error message would appear in the [ERROR] field and the text box will display the instructions how to fix it.

I went into the text box and opened the expression to build a Dlookup. I am having issues with it.

I have 2 tables.
tbl Instructions with 2 fields, [Fuel Error] and [Instructions]

tbl Fuel Errors with 10 fields one of which is named [ERROR] (this is where the error message would be).

I tried this expression so far, it doesn't have any syntax errors but it doesn't return the instructions either.

=DLookUp("Fuel Error","tbl Instructions","Instructions = " & DLookUp("ERROR","tbl Fuel Errors","Instructions"))

What am doing wrong?
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
You can only look up 1 field in 1 table with DLookup. Second, if this
tbl Fuel Errors with 10 fields one of which is named
means you have an error message field for each of 10 errors you have identified, this is wrong. Databases are based on rows; spreadsheets on columns (fields). I have to guess here a bit, but:
You should have tblErrors with ErrorID (an autonumber field should suffice) | ErrText holding such as ADDRESS TO FOLLOW (ERROR is a reserved word and should not be used). Because errors and their associated text are an entity of their own, they should have their own table. Each error text value is a row, not a field. The PK (autonumber) field is what's stored in the other table, but I can't really say how because I don't get the structure or use of it. If it's some sort of delivery record and contains info about deliveries, what shows in that table is 8 (error number 8 from tblErrors) not the text of the error. Same holds true if what you also want is the solution to the error in that record as well. Thus your form query includes the error table and returns the error text and solution based on the error number in the delivery record. If there is only 1 solution per error, one errors table could do it, but in truth there should be 2. Errors and solutions are really each an entity of their own, and as mentioned, each entity should have its own table. You should not have to redesign (add fields) should you identify an 11th error, or suddenly want to have more than one solution for them. This indicates improper design.
I'd post links on db normalization and relational theory if you want. Did that for someone else today without asking and got grief for insulting their intelligence.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,589
Messages
6,120,416
Members
448,960
Latest member
AKSMITH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top