DLookup in a report doesn't work when put the report in a navigation form (1 Viewer)

dzgr

New member
Local time
Today, 10:29
Joined
Jun 24, 2019
Messages
4
<solved>DLookup in a report doesn't work when put the report in a navigation form

Good morning everyone,

I am new to Access and to the forum. I've attempted to use a DLookup as a control source in a report like this:

=DLookUp("txtVehicleName","tblVehicle","VehicleID=" & [Reports]![rptMountingPosition]![Vehicle_FKID])

It works well when I open the report direktly from the left navigation pane. But thing became weired when I creat a navigation form and put this report into it. It does not work any more, only shows a "#Name?" error message.

Is there anyone could give me a hand?

Thanks very much.
 
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 09:29
Joined
Feb 19, 2013
Messages
16,553
I presume by
creat a navigation form and put this report into it
you mean you are displaying the report via a subform. In which case please clarify how you did this - by dragging the report onto the navigation form? or some other way?

In which case this

[Reports]![rptMountingPosition]![Vehicle_FKID]

needs to be something like

[navigationformname].[nameofsubformcontrol].form![Vehicle_FKID]
 

dzgr

New member
Local time
Today, 10:29
Joined
Jun 24, 2019
Messages
4
Hello CJ_London,

Thanks for your hints. I dragged the report onto the navigation form, just like many tutorial said. And I'v followed your hins change the control source like this:

=DLookUp("txtVehicleName","tblVehicle","VehicleID=" & [Forms]![frmNavigation]![NavigationSubform].[Form]![Vehicle_FKID])

This time the error message became #Type! .... what could be the reason?

Thanks a lot.
 

dzgr

New member
Local time
Today, 10:29
Joined
Jun 24, 2019
Messages
4
I've also googled the same problem. It seems not be a Null/Zero or data format problem...so strange....
 

dzgr

New member
Local time
Today, 10:29
Joined
Jun 24, 2019
Messages
4
Oh man, I solved it by changing the code like this:

=DLookUp("txtVehicleName","tblVehicle","VehicleID=" & [Vehicle_FKID])

Unbeliveble, it's so that simple.
 

Users who are viewing this thread

Top Bottom