Userform

B

Bre-x

I have create a user form data connect to an ms access db
My ListBox1 shows email address.

I would like to double click on a record so that the email value
will be paste on my New Email's To field.

Thank you all

Bre-x
 
B

Bre-x

I need the VBA code to put on my listbox double click event.
So that the address will be paste on the "To" box on the new email form.

thnks
 
J

JP

In your listbox double click event:

Call CreateEmail(ListBox1.Value)


Then somewhere else in your form class:

Function CreateEmail(emailAddr As String)
Dim Msg As Outlook.MailItem

Set Msg = Application.CreateItem(olMailItem)

Msg.To = emailAddr
End Function

Customize as needed.

--JP
 
B

Bre-x

Hi JP

Thanks for anwering my post.

Unfortunately, It does work. The value of the listbox is not paste into the
"To" field.




In your listbox double click event:

Call CreateEmail(ListBox1.Value)


Then somewhere else in your form class:

Function CreateEmail(emailAddr As String)
Dim Msg As Outlook.MailItem

Set Msg = Application.CreateItem(olMailItem)

Msg.To = emailAddr
End Function

Customize as needed.

--JP
 
J

JP

I assume you meant it does *not* work.

We need more information to diagnose.

Where are you putting this code?
Can you be more specific than "it doesn't work?"
Is the code in the proper place?
Is there an error? If so, what is the error code and text of the error
message?

--JP
 

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