A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

linking subform to mainform field



 
 
Thread Tools Display Modes
  #1  
Old May 6th, 2005, 05:29 PM
Pearl
external usenet poster
 
Posts: n/a
Default linking subform to mainform field

I have a main form that has a field called LastName. I also have a subform
that also has a field called LastName. I placed that field in the subform to
be able to correlate the subform to the mainform BUT what I want is that each
time I open the form to a specific LastName in the main form that the subform
field called LastName will auto populate with the same value in the mainform
field called LastName. How do I do this? I have done this a long time ago
but can not remember how I did this. I recall I did this completely using
the Build option in properties of the field and did not use VBA ( I am not
versed in VBA and would prefer to not do this in VBA). Can anyone assist?


  #2  
Old May 6th, 2005, 06:42 PM
Sprinks
external usenet poster
 
Posts: n/a
Default

Hi, Pearl.

A subform is linked to a main form by the LinkMasterFields and
LinkChildFields properties of the subform, which are the matching fields in
the main and subform's record sources, respectively. Since a main
form/subform is used to display a one-to-many-relationship (one main form
record with many subform detail records), this field is normally the primary
key of the main form record source and a corresponding foreign key in the
subform. For example:

Customer: ABC Corporation
Address: 1234 Lincoln Hwy.
etc...more main form fields

Orders:
Order # Order Date OrderStatus
--------------------------------------------------
1234 1/1/05 Closed
1356 2/3/05 30 Days Past Due
....more Order records

Notice the linking field (CustomerNumber) need not be *displayed* in either
form, but it must be a field in each of the forms' record sources.

I'm kind of surprised you'd be linking by a last name, which normally would
never be used as a primary key. I also don't understand why you would want
to display the name on the subform also; it doesn't add any new information.

Hope that helps. If you need any further discussion on the last topic,
please provide more detail about the generic purpose of your application and
its tables.

Sprinks


"Pearl" wrote:

I have a main form that has a field called LastName. I also have a subform
that also has a field called LastName. I placed that field in the subform to
be able to correlate the subform to the mainform BUT what I want is that each
time I open the form to a specific LastName in the main form that the subform
field called LastName will auto populate with the same value in the mainform
field called LastName. How do I do this? I have done this a long time ago
but can not remember how I did this. I recall I did this completely using
the Build option in properties of the field and did not use VBA ( I am not
versed in VBA and would prefer to not do this in VBA). Can anyone assist?


  #3  
Old May 7th, 2005, 06:49 AM
John Vinson
external usenet poster
 
Posts: n/a
Default

On Fri, 6 May 2005 09:29:16 -0700, "Pearl"
wrote:

I have a main form that has a field called LastName. I also have a subform
that also has a field called LastName. I placed that field in the subform to
be able to correlate the subform to the mainform BUT what I want is that each
time I open the form to a specific LastName in the main form that the subform
field called LastName will auto populate with the same value in the mainform
field called LastName. How do I do this? I have done this a long time ago
but can not remember how I did this. I recall I did this completely using
the Build option in properties of the field and did not use VBA ( I am not
versed in VBA and would prefer to not do this in VBA). Can anyone assist?


I see Sprinks has provided you with the answer (thanks!) but let me
just amplify on one point he made.

Names ARE NOT UNIQUE.

If you have eleven different people all named Smith in your database,
and seven named Brown, which person's data do you want to see on the
subform?

Or do you tell the second Smith "I'm sorry, we can't do business with
you, there's already someone named Smith in our database?"

Use a unique PersonID instead; and as Sprinks says, there's probably
no good reason to display the same name on both the form and the
subform.

John W. Vinson[MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Design help, please SillySally Using Forms 27 March 6th, 2005 05:11 AM
Update field value automatically based on subform Sammie Using Forms 0 February 11th, 2005 10:49 PM
Form Subform data export [email protected] Using Forms 6 January 6th, 2005 07:25 PM
Need help with cascading combos Tom Using Forms 19 July 1st, 2004 11:11 PM
Recordset in subform based on field in parent form Lyn General Discussion 15 June 14th, 2004 03:10 PM


All times are GMT +1. The time now is 09:37 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.