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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto-populate Subform with Info from Field in Form

Status
Not open for further replies.

pcolvin

Technical User
Oct 17, 2008
22
US
I have a form which has a number of subforms. Speciifically, I have created a subform form called "Contact Log." The contact log is an area in which the user can enter a new record for each instance of contact made between our company and another organization. The main form and each subform contain a field called "Organization Name." I want the subform "Organization Name" field to autopopulate with the information contained in the main form's "organization name" field.
 
Do you want the Organization Name to display only or to save? Isn't there a field value in the subforms that can be used to identify the Organization Name?

Can you provide the significant table and field names in the record sources and how they are related?

Duane
Hook'D on Access
MS Access MVP
 
I need the "Organization Name" field to save the org name from the main form's org name field to the subform's org name field. I can get it to work, but I then recieve the following message when I try to create a new record:

Field 'Contact.OrganizationName' cannot be a zero-length string.

If I set the record source table field "OrganizationName" to Allow Zero-length the field in the subform longer autopopulates. If I set it to not Allow Zero-lenth, the subform autopopulates, but I get the string message above.

Is there a way to supress the string message?

 
How are ya pcolvin . . .

Since its universally known that all organization contacts are made with your company, why wouldn't a single textbox in the mainform ([blue]with a larger bolded font[/blue]) be sufficient for identifying the organization for all subforms?

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
The form / subform relationship is based on the OrganizationName field. The contact subform filters all the records so that only the records with an OrganizationName that matches the current main form OrganizationName field are listed. The users do not see the OrganizationName field in the subform, its only used for filtering purposes.
 
I'm not sure why you choose to ignore
Duane said:
Can you provide the significant table and field names in the record sources and how they are related?

Aren't you using the Link Master/Child properties to synchronize the values of the field?


Duane
Hook'D on Access
MS Access MVP
 
Sorry,

I am using a Master/Child properties to synch the fields, but that requires the fields to be populated with information. I don't want users to have to retype the org name into the subform, I want it to autopopulate.

The tables are:
tblContactTable
Contact

The forms/fields are:
frmContactDetails.OrganizationName
sfrmContact.OrganizationName

The sfrmContact.OrganizationName should autopopulate with the same information as in the current frmContactDetails.OrganizationName field.

 
I'm confused. If you set up the Link Master/Child properties on your subform, the value from the main form will automatically be entered into the subform for all new records. You can choose to display the value in the subform or not. You don't have to enter the value in the subform because it's automatic.



Duane
Hook'D on Access
MS Access MVP
 
Then I am confused too, because I have the Link Master/Child properties set on my subform, but the values are not being automatically entered into the subform.
 
Is OrganizationName the primary key field in tblContactTable? Are you entering information into the main form first and then entering information into the subform?

Do you have a relationship set between:
tblContactTable.OrganizationName and Contact.OrganizationName

Typically names aren't used for linking. I would normally expect to see a primary key in tblContactTable like "OrganizationID" or similar.

If you are still confused, try again to answer my question "Can you provide the significant table and field names in the record sources and how they are related?" with greater details on table and field names, data types, and the relationships.

Duane
Hook'D on Access
MS Access MVP
 
Many people have worked on this database in the past and used a number of methods I would not have chosen myself.

The Organization name is the primary key for the main table (tblContactTable). This works since each organization's name is unique and duplicates are not allowed.

That tables relationship with the other table (Contact) is "1: Only include rows where the joined fields from both tables are equal."

Master Fields: frmContactDetails.OrganizationName
Child Fields: sfrmContact.OrganizationName

Result: Show Contact for each record in ,SQL Statment. using OrganizationName

Right now I can get it the subform to show the OrganizationName using the default value =[Forms]![frmContactDetails]![OrganizationName], but when I start a new record in the subform it disappears.

If I change the Contact table's OrganizationName field properties to NOT allow zero-length strings, the OrganizationName is populated into the subform, but then I recieve the message "Field 'Contact.OrganizationName' cannot be a zero-length string" when I start a new record.

I have tried a bunch of differ ways to connect the form to the subform and every time I cannot get it to automatically populate the linked field. Users have to retype the information into the subforms.
 
I fixed it!!! A previous programmer added a second "OrganizationName" field to the main form which was the cause of all the issues. I didn't see it because it was layered beneath another subform.

THANK YOU FOR YOUR HELP!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top