DLookUp Referencing in Control on Subform #Name Error (1 Viewer)

Pauline123

Registered User.
Local time
Today, 15:21
Joined
Apr 1, 2013
Messages
69
Help! I am slowly losing the will to live :(

I have a control on a subform that uses the DLookUp function to get a numerical value from a query.

When I use the following in the subform it works fine:

=DLookUp("[TotNoDays]","qryHolEntitCalculation","[HPIDNo]=" & [Forms]![HolidayTakenForm]![ HPIDNo])

But when I use the following when the subform is nested in the main form I keep getting the #Name error:

=DLookUp("[TotNoDays]","qryHolEntitCalculation","[HPIDNo]=" & [Forms]![HolidaysMainForm].[Form]![HolidayTakenForm]![HPIDNo])

The subform is linked to the main form via the EmployeeID number.

Have attached example of problem - tried various combinations without success. Heeelllllppppp - Pauline
 

Attachments

  • DLookUp.zip
    448.8 KB · Views: 112

Ranman256

Well-known member
Local time
Today, 10:21
Joined
Apr 9, 2015
Messages
4,337
ALWAYS use the picker builder....is spells the path correctly...
yours is probably
[Forms]![HolidaysMainForm]![HolidayTakenForm].[Form]![HPIDNo]


form![formname]![subformname]!form![controlName]
 

sneuberg

AWF VIP
Local time
Today, 07:21
Joined
Oct 17, 2014
Messages
3,506
If you check this handy web site you will find this form for the reference in this case

Code:
Forms!Mainform!Subform1.Form!ControlName

So if [HolidayTakenForm] is the name of the subform control you would want

Code:
Forms![HolidaysMainForm]![HolidayTakenForm].Form![HPIDNo]

You can verify this in the query designer by typing in a criteria field and Intellisense will help you create the reference. It's best to have all forms and subforms open when you do this.
 

Pauline123

Registered User.
Local time
Today, 15:21
Joined
Apr 1, 2013
Messages
69
Hey sorry only just getting back to you guys - your info was great but I realised that all I needed to do was just reference the text box on the sub form and it worked a dream - hate mental blocks lol but thanks for your input very much appreciated - Pauline
 

Users who are viewing this thread

Top Bottom