forms and subform

L

Lauren B

How can I refer to fields on a form when I'm creating code for a command
button on a subform?

For example, I'm trying to create a command button that automatically opens
an e-mail. In the subject of that e-mail I want the Name and State of the
customer I'm refering to. C_Name and C_State are both fields on the overall
form, while the command button is located on a subform within that overall
form.

If all fields were on the same form I would write:

DoCmd.SendObject , , , e-mail address, , , "Received", [C_Name] & ", " &
[C_State]

How can I specify the form location of C_Name and C_State

Thank you for any assistance. It is greatly appreciated.

LB
 
A

Alex White MCDBA MCSE

Hi Lauren

if your outer form was called form1 with a textbox call text1

then Form_Form1.text1.value should provide you what you want,

you may find it better to create some variables and copy the values into
them first then reference

e.g.

Dim strFirst_Name as stirng
strFirst_Name = Form_Form1.text1.value


THIS IS NOT COMPLETE but shows you what to do

DoCmd.SendObject , , , e-mail address, , , "Received", strFirst_Name & ", "
&
[C_State]

Hope it helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top