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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
prefilling controls on a form
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 |
#2
|
|||
|
|||
prefilling controls on a form
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 -----Original Message----- 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 . |
#3
|
|||
|
|||
prefilling controls on a form
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/WileyT...764559036.html "Nathan Sanders" wrote in message ... 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 |
Thread Tools | |
Display Modes | |
|
|