DLookup value does not show in Form View (1 Viewer)

Threcian

New member
Local time
Today, 19:57
Joined
Feb 11, 2016
Messages
5
<Solved> DLookup value does not show in Form View

I have a database form in which there are two text boxes. The first one is S_IDText and the other is Text92. In the Text92 box I want to display the Source name that corresponds to the number present in the S_IDText. I'm doing this by using

=DLookUp("[S_Name]","[Sources]","[S_IDText].[Text]=" & "[Sources].[S_ID]")

Sources is the table name.
S_Name is a text field that is the Source Name inside the Sources table.
S_ID is a number field that is a unique number for each source.

The form basically scrolls through KPI names and their S_ID. So whenever the S_ID is displayed, I want Text92 to display the source name. The form record source is the KPI table.

The issue is that in Layout view Text92 shows the S_Name no problem. But in Form View it shows up blank and tweaking the code around gives me #Type! or #Name! errors.
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:57
Joined
May 7, 2009
Messages
19,246
you have them reversed in your function call, should be:

=DLookUp("[S_Name]","[Sources]","[S_ID] = " & [S_IDText])
 

Threcian

New member
Local time
Today, 19:57
Joined
Feb 11, 2016
Messages
5
Thank you. It's working perfectly now.

I had it like how you suggested but I had [S_IDText] in quotes. I'm new to Access (2 weeks) and I'm still unsure where to add and avoid quotes.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:57
Joined
May 7, 2009
Messages
19,246
if its a the field on your table is text use quote mark, use Chr(34) to be safe, ie:

"[textField] = " & Chr(34) & Me.yourtextbox & Chr(34)

if the field is numeric, without qoute:

"[IDfield] = " & Me.yourtextbox

if it is date, enclosed in hash symbol, and use US date format:

"[dateField] = #" & Format(Me.textbox, "mm/dd/yyyy") & "#"
 

Users who are viewing this thread

Top Bottom