Continuous Form Question

thechazm

VBA, VB.net, C#, Java
Local time
Today, 10:40
Joined
Mar 7, 2011
Messages
515
I have a continuous form that displays some basic data. My question is how do I display the data referenced from a different table from a control in the form?

Eg. I have two tables
tblLocations
tblInspection

When the user inputs the results in the tblInspection table it has a field that is called Locations. This stores the AutoNumber from the tblLocations table.

In the form I would like it to display the [Location] data from tblLocations using the number as the reference and still show the rest of the data from tblInspection.

If I am unclear then I am very sorry,

Thanks

TheChazm
 
Hiya,

You can use DLookup to display data from an unrelated table, something like;

DLookup("[Location]", "tblLocations", "[COMMON FIELD NAME IN tblLocations] = Forms![FORMNAME]![FIELD ON FORM NAME]"

Place the code in one of the events (maybe AfterUpdate)

if you want to display more than one field why not have a related subform?

Take Care
Smalltime
 
ah just spotted the continuous form bit.

In this case you'll have to base the form on a query that has data from both tables.

Sorry
SmallTime
 
Thanks for the reply. I was just wrapped around doing this in code since I have never made a form based on a querry that would be updatable. Tunnel vision :)
 
no need for any code

base your form on a query containing both tables.
 
The answer by smig is the best solution but only if the query is updateable.

Otherwise an alternative to subforms (which aren't supported in Continuous Forms) is to display both forms as subforms. Place a control on the main form with a controlsource refering to the subform field as would normally be the LinkMasterField in a typical form/subform arrangement.

Then use this control as the LinkMasterFiled in the other subformcontrol. This makes the second subform track the first. It am pretty sure it works better than a DLookUp though I have never done a proper comparison.
 

Users who are viewing this thread

Back
Top Bottom