prefilling controls on a form

  • Thread starter Thread starter Nathan Sanders
  • Start date Start date
N

Nathan Sanders

Hi

I have two forms FrmA and Frmb.

A command button on FrmA is used to open FrmB.

What code do I need to use to prefill controls on FrmB with values from
FrmA?

Thanks
Nathan
 
Nathan,

You can use the default value property:
In your control(s) on FrmB use =[forms]![frmA].
[controlname] put this into the default value in the
properties. The assumption here is that FrmA is still open
and populated.

HTH,

Terry
 
Nathan,

You have three options:

1. If FormB is bound to a table or query, the appending a WHERE clause to
the DoCmd.OpenForm method will populate FormB with the appropriate data. For
example:
DoCmd.OpenForm "FormB", , , "SomeField = somevalue"

2. You can push the values into FormB's controls using their fully-qualified
names. For example:
DoCmd.OpenForm "FormB"
With Forms!FormB
!txtSomeTextbox = "abc"
!txtAnotherTextbox = 2
End With

3. You can add some properties to FormB, instantiate it from FormA, and
populate the fields as you would any other object. See the following page
for an example of this:
http://www.pacificdb.com.au/MVP/Code/MyDialog.htm

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Back
Top