Labeling a Text Box with Dlookup?

Drrellik

Well-known Member
Joined
Apr 29, 2013
Messages
842
Office Version
  1. 365
  2. 2016
  3. 2013
  4. 2011
  5. 2010
Platform
  1. Windows
I have an aerial photo with several Textbox's on it. I have a simple table with several columns from which I created a query with two columns. Location & New ID I am using the following =DLookUp([ALL Query2]![New ID Number],[ALL Query2]![Location],"Target 102-1") in the control source under the data tab of the text box. I get ?#error in the textbox is it a syntax error or am I going about it wrong? the ID I am looking to return is the primary key as well.

Thanks DR
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
You cannot return data from 2 fields with DLookup. What you have looks like a sql statement, and you cannot set the control source of a textbox to a sql statement either. Nor can you return multiple records to a textbox, which is another thing you are trying to do (even if this statement only returns one record, I believe the assumption is made by Access that the data source could). Nor should you (normally) return 2 or more fields to one textbox. You'll have to rethink your approach, AFAIC. Maybe change to a combo, or listbox, (either of which will solve the multi-field, multi-record issue) or have a textbox for each field and concatenate the two into a third if you must have them combined.
 
Upvote 0
I think you might be able to return two fields with TWO DLookups:
=DLookUp([ALL Query2]![New ID Number]) & DLookup([ALL Query2]![Location]) & "Target 102-1"

Above is untested. You may need to adjust syntax and if the DLookups return numeric data you may need to cast to string in order to concat with strings.
 
Upvote 0
I will try your suggestion.

I would also like to restate my question because I am very new to Access.

My data is Location : ID

My photo has a small text box I created with nothing in it.

What I want to return in the box is only the ID

so once the target is damaged and I remove it, I will place a new target in its place and I will change the location column for that ID to Salvage and then find my new Target ID and change that Location to Target 102-1

Then on my Map I was hoping to just have it populate the textbox with my "new" ID number that correlates with that location.


I hope that made sense. It is hard something to articulate your end result's.


Don.


If a text box is not the way to go, I am open to suggestions.


Don
 
Upvote 0
It sounds like you are trying to do a lot of things - updates (change records), deletes (remove records), inserts (add new records). And it doesn't sound like you know a great deal about working with databases. Not sure how to give advice in this case. Might be better to use Excel!
 
Upvote 0

Forum statistics

Threads
1,221,819
Messages
6,162,155
Members
451,749
Latest member
zack_ken

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