UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> HOW TO make one textbox control to receive a multiple entry    
 
   
rjAccDB
post May 21 2009, 11:23 AM
Post #1

UtterAccess Guru
Posts: 909
From: Phil



Hello UA,

Can someone please guide me through:

1. I have a form (Entry Form) and one control is an "Email Address", how can I make the textbox control to receive more than one entry (email addresses).

2. How to make a list box of emails, after selecting the email, I have a button (Add) to click and the selected item will copied to my "Email Address" control above.

Appreciate any help please.

Many thanks
rj

NOTE: My form is a bound form..

Edited by: ksalearnsaccess on Thu May 21 12:24:03 EDT 2009.
Go to the top of the page
 
+
Jack Cowley
post May 21 2009, 11:36 AM
Post #2

Retired Moderator
Posts: 37,716
From: The San Francisco Bay Area



You do not want to put more than one email address into a field in a table. If someone has multiple email addresses then create a related table and save each email as a RECORD in that related table.

As for your second question - You could use a Multi-Select list box then used code to add the selected emails to the table I mentioned above....

hth,
Jack
Go to the top of the page
 
+
rjAccDB
post May 21 2009, 11:44 AM
Post #3

UtterAccess Guru
Posts: 909
From: Phil



Hi Jack,

Thanks for picking my post very quick.

No, my recipient will have only one email ad, but sometime, it will be more than one recipient.

On your second statement, I can only built listbox using the wizard, how can I built a multiselect listbox, and what would be the Adding Code into my email address textbox.

Question, is textbox capable of receiving multing entries? that would be separated with semi-colon ((IMG:http://www.utteraccess.com/forum/style_emoticons/default/wink.gif) ?

Thanks again Jack,
rj
Go to the top of the page
 
+
Jack Cowley
post May 21 2009, 12:09 PM
Post #4

Retired Moderator
Posts: 37,716
From: The San Francisco Bay Area



rj -

Do not save more than one 'recipient' in a field in a table. If you need a string of recipients then build it as needed, but do not save multiple pieces of data in a field in a table.

A text box is capable of holding more than one recipient, but the text box should be unbound so that data is not saved to your table.

You can create your list box using the Wizard and then you can change the Multi Select property to Simple.

This code will concatenate the selected items in the list box:

CODE
Dim varItem As Variant
Dim strList As String

For Each varItem In Me.NameOfYourListbox.ItemsSelected
     strList = strList & ", " & Me.NameOfYourListBox.ItemData(varItem)
Next varItem

Me.NameOfUnboundTextBox = Mid(strList, 2)


The code assumes that email address is in the first column of the list box...

hth,
Jack
Go to the top of the page
 
+
rjAccDB
post May 22 2009, 09:11 AM
Post #5

UtterAccess Guru
Posts: 909
From: Phil



Hi Jack,

I will try to change my "Email Recipient" into unbound control. I'm afraid if my SEND button code will still work, but let me try it in my office tomorrow.

Does the code u gave copy the selected email into my recipient control? Suppose I will put the code on "OnClick Event of my Add button?.

Many thanks Jack,
rj
Go to the top of the page
 
+
Jack Cowley
post May 22 2009, 01:32 PM
Post #6

Retired Moderator
Posts: 37,716
From: The San Francisco Bay Area



rj -

The code puts the list of emails into a string called 'strList' and it can put it in your 'recipient control' as well. If this code is on the same form as your button to send emails then you can put strList as the variable for the 'email recipient' part of your code to send emails...

The code would gon in the On Click event of a button that you click after you make your selection in the list box....

hth,
Jack
Go to the top of the page
 
+
rjAccDB
post May 25 2009, 11:12 AM
Post #7

UtterAccess Guru
Posts: 909
From: Phil



Hi Jack,

Sorry for stay off long.

The code you provided is worked perfect, thanks a lot Jack.

Minor touch up Jack, if you can spare minute with me.

I tried to clear my recipient email (unbound text) on the click of my NEW button but it didn't cleared up by the following code:

Me.recipient_email = ""

What is wrong with this code.

Thans in advance Jack,
rj
Go to the top of the page
 
+
rjAccDB
post May 25 2009, 11:29 AM
Post #8

UtterAccess Guru
Posts: 909
From: Phil



Hi Jack,

Just a small clarification regarding your;

----
The code assumes that email address is in the first column of the list box...
----

Jack how can I make that the code will get the value in the second column of my list box?

I want to list first the name then the email address.

thanks again,
rj
Go to the top of the page
 
+
Jack Cowley
post May 25 2009, 11:31 AM
Post #9

Retired Moderator
Posts: 37,716
From: The San Francisco Bay Area



rj -

The code works for me. I would rename the control RecepientEmail (no space) and then try your code. This should work as well:

Me.ReccepientEmail = Null

Good Luck!

Jack
Go to the top of the page
 
+
Jack Cowley
post May 25 2009, 11:55 AM
Post #10

Retired Moderator
Posts: 37,716
From: The San Francisco Bay Area



rj -

CODE
Dim varItem As Variant
Dim strList As String

For Each varItem In Me.NameOfYourListbox.ItemsSelected
     strList = strList & ", " & Me.NameOfYourListBox.Column(1, varItem)
Next varItem

Me.NameOfUnboundTextBox = Mid(strList, 3)


This should do the trick. Remember that list boxes are zero based so the second column is column 1

hth,
Jack
Go to the top of the page
 
+
rjAccDB
post May 29 2009, 12:01 AM
Post #11

UtterAccess Guru
Posts: 909
From: Phil



Hi Jack,

Many thanks for the help, everything is worked just fine.

rj
Go to the top of the page
 
+
rjAccDB
post May 29 2009, 12:27 AM
Post #12

UtterAccess Guru
Posts: 909
From: Phil



Jack,

How can I use NZ function in my send code so that it will accept a null in CCRecipient control. I noticed that if there is no content in my CCRecipient it stop the sending.

Thanks again,
rj
Go to the top of the page
 
+
Jack Cowley
post May 29 2009, 08:19 AM
Post #13

Retired Moderator
Posts: 37,716
From: The San Francisco Bay Area



I think this is what you are after:

Me.NameOfUnboundTextBox = Nz(Mid(strList, 3), "")

UNTESTED!

hth,
Jack
Go to the top of the page
 
+
rjAccDB
post May 29 2009, 11:19 AM
Post #14

UtterAccess Guru
Posts: 909
From: Phil



Thanks Jack, let me try tomorrow in my office.

I hope this will handle the null error if sending no value on CCRecipient.

Many thanks once again,
rj
Go to the top of the page
 
+
Jack Cowley
post May 29 2009, 04:34 PM
Post #15

Retired Moderator
Posts: 37,716
From: The San Francisco Bay Area



rj -

I am not at all familiar with the code you are using to send emails so I do not know how a Null CCRecpient is handled and what you need to do so that if it is null the code does not error out...

Jack
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 24th May 2013 - 03:24 AM