Value to an unbound field

  • Thread starter Thread starter Dimitris Nikolakakis
  • Start date Start date
D

Dimitris Nikolakakis

I have a form FORDERS that takes data from table ORDERS

One field of this form is FactoryID.

I have an unbound field named SentTo and I want to automatically give the
value of Factories.E-mail (field of table FACTORIES) based on the field
FactoryID of the form.

The above form opens from a command button of a form and shows only one
record (FILTER) when loaded.

Thanks
 
You will need the FactoryID field in the Factories table to do this. Set the control
source of the unbound textbox to

=DLookup("[E-mail]", "Factories", "[FactoryID] = " & Forms!FORDERS!txtFactoryID

if the FactoryID is text instead of numeric

=DLookup("[E-mail]", "Factories", "[FactoryID] = '" & Forms!FORDERS!txtFactoryID & "'"
 
Use a DLookUp when your form loads:

Dim strFID as String
Dim strFEmail as String

strFID = [FactoryID]
strFEmail = DLookUp("[E-mail]","FACTORIES","[FactoryID]='"
& strFID & "'")
[SentTo] = strFEmail

Check the Help files for more details on DLookUps.

Hope this helps!

Howard Brody
 
Back
Top