You are here:

Using MS Access/Pass value from main form to subform

Advertisement


Question
Hi Scott,

What is the vba code to pass value (date) from a main form to a subform? Do I have to make a field in the subform unbounded for this? Will it work if this field in the subform has to be hidden?

Thank you.

Answer
No VBA. Simply set the Default Value of the date control to:

Forms!mainformname!controlname

Whenever you add a new record that control (and therefore the underlying field) will be populated with the date on the mainform.

If you want to use VBA you can use the Before Insert event and:

Me.datecontrol = Forms!maninformname!controlname
or
Me.datecontrol = Me.Parent.controlname

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scottgem

Expertise

I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience

I've been designing databases for over 25 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

Education/Credentials
Brooklyn College BA

©2016 About.com. All rights reserved.