Re: Automatically populate a form field

From: Gerald Stanley (gcstanley_at_dsl.pipex.com)
Date: 04/14/04


Date: Wed, 14 Apr 2004 10:25:39 -0700

It sounds like you need to change the DoCmd.OpenForm to
include a where parameter e.g.
DoCmd.OpenForm "Form2",,,"yourColumn = '" & Me.txtField & "'"

You will have to change yourColumn and txtField to suit
your app. I have assumed that the joining column is a text
field. If it is a number, you sshould drop the '
surrounding Me.textField

Hope This Helps
Gerald Stanley MCSD
>-----Original Message-----
>Okay this worked but now I notice that when form 2 opens,
>I am forced to jump through the records in order to find
>the corresponding one. It starts with the first record in
>the form 2 table rather than the record that corresponds
>to the Main Form. Thoughts?
>
>
>>-----Original Message-----
>>Thank you!
>>
>>
>>>-----Original Message-----
>>>If Form2 is being opened as non-modal, your code should
>>>look something like
>>>DoCmd.OpenForm "Form2"
>>>Forms!Form2!txtCustomerName = Me.txtCustomerName
>>>
>>>You will have to change txtCustomerName to the control
>>>names that you have on your forms.
>>>
>>>Hope This Helps
>>>Gerald Stanley MCSD
>>>>-----Original Message-----
>>>>If I have 2 forms, one being the main form and the
>>second
>>>>being form two, how can I populate a field in form 2
>>when
>>>>it is triggered by the main form?
>>>>
>>>>For instance, If I select and option button in the main
>>>>form that triggers form 2, I would like the name of the
>>>>Customer from the main form to be populated in the form
>>2
>>>>CustomerName field.
>>>>
>>>>Any help would be appreciated. Thanks!!
>>>>.
>>>>
>>>.
>>>
>>.
>>
>.
>