Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lookups and multiple fields

Status
Not open for further replies.

bnjoplr

Programmer
Aug 14, 2002
7
US
I have a form with a subform. The lookup on the main form
is fldStreetName and that writes to the same field on the
underlying table. I want to also be able to write the
fldStreetID to the underlying table, but can't figure out
how to accomplish that.

Any help would be appreciated. Thanks!

Bobbi
 
Within the Link Child Fields and Link Master Fields properties you can specify more than one field. Separate each with a semicolon. So in your example, use "fldStreetName;fldStreetID" in both properties (although probably better to list the PK first if that is fldStreetID - just make sure both properties are in the same order). This will ensure both fields of the subform are populated.

You could also populate the field within the Form_BeforeInsert event of the subform by looking up the Parent form's field. This will avoid limiting the subform to records that match both fields if that becomes a problem.
e.g. Me.txtfldStreetID = Me.Parent.txtfldStreetID
 
This solution doesn't seem to be working for me. The street name field is a lookup. I've included the ID field in the query for the lookup, but it writes the street name to the table. I also need to write the Street ID field. When I tried to link child/master fields, I don't see the the ID from the Streets table. If I just type it in as you suggested, I lose functionality. Same thing happened when I used the code.

Any other thoughts?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top