Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help setting a variable value from field

Status
Not open for further replies.

PaulMThomas

IS-IT--Management
Aug 2, 2004
133
GB
I am sure this is pretty easy but my MS Access skills are pretty poor.

I have a record open on a form, one of the fields is E-MailAddress within a table called tbl_Customer_Site_Contact.

How do I set a variable called v_EMailAddress to the value of the current record field E-MailAddress?

In case it is required to know why I am doing this, it is is so that I can send an e-mail to the user.
 
What about this ?
v_EMailAddress = Me![E-MailAddress]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV

Thanks for your help.

I have done as suggested:-

Private Sub Btn_E_Mail_Click()
Dim v_ForeName, v_EMailAddress, v_Subject, v_Message

v_EMailAddress = Me![E-MailAddress]
v_ForeName = Me![ForeName]


I get the following message:-

Run-time error '2465'.
Hotline call logging system can't find the field 'E-MailAddress' referred to in your expression.

I assume I need to tell it which table to look in?

 
Also, is it possible to put carriage returns in a text variable to format a e-mail message.

For example

Line1
Line2
Line3
Line4

Thanks

Paul
 
My suggestion was for getting the value of a control in the current record of the form.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The form shows a record from the Hotline call table, there is also basic data from the Customer , Site and Contact tables. The e-mail address field is not on the form. However the correct Customer, Site and Contact record should be current, I just need to read the value of the E-MailAddress field.

Thanks

Paul
 
The easiest way is to add a control (a text box) on the form then set the value equal to the e-mail address. That way PHV's way will work. Otherwise you will need to open a recordset set to the current record then "select" the address. PHV as I assumed that there was a control on the form with the address.
 
You may consider the DLookUp function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top