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

Interacting with subforms

Status
Not open for further replies.

raddster

Programmer
Apr 5, 2001
15
US
I have a main form with individual records from my contacts table and a subform datasheet view of all the records in the contacts table. As I move from record to record in the main form the subform updates and refreshes to show all the contacts.

Here's my problem... I'd like to click on a contact in the subform and have the main form move to the record selected on the subform. I've tried every way I can think of to accomplish this but have been unsucessful thus far. It's probably so simple that I've missed it.

Any help would be GREATLY appreciated.

Thanks,
Steve
 
Hi,

if you are displaying the whole contacts in the subform and would like to show individual record in the main form based on subform selection, you can set the fields' control source property in the main form to the subform's fields.
Example:
in the main form, controlsource of txtName = [subform]![Name]
This way the record displayed in the main form will be as selected in the subform.

See if this is what you want and good luck!

Tin Tin
 
Thank you TTThio.

Your suggestion works, however ALL the fields from the mainform are not in the subform. Is there a way to get the record pointer in the table by clicking on a record in the subform and then pass it to the mainform and have the mainform repaint with that record being displayed?
 
Hi again raddster,

if the fields in the mainform are not in the subform, then you can write a code in the subform_current event that requery the mainform record source based on the selection.

Exp:
Sub subfrom_current()

Mainform.recordsource = "Select * From Table Where [tableFieldX] = '" & me.FieldX "'"

The main form and subform have to have at least one same field then can set the criteria even this field is not necessarily displayed in the main form.

Hope this work.

Tin Tin

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top