Refer to control in closed form

M

MSU Sptn

I have a form set up to grab email addresses stored in a text box on a
different form. When I try to send the emails, an error occurs stating that
the closed form cannont be found. Is there a way to grab data from a text
box on a closed form?
 
D

Dirk Goldgar

MSU Sptn said:
I have a form set up to grab email addresses stored in a text box on a
different form. When I try to send the emails, an error occurs
stating that the closed form cannont be found. Is there a way to
grab data from a text box on a closed form?

Forms don't hold data -- the tables to which they are bound do. Forms
are just windows on the data. You can't get data from a form that is
closed, but you can go out to the table where the data is stored and get
it.

Check the form design to find out what table contains the email-address
field you want, and what the name of the field is in that table (it may
be the same as the name of the text box, or it may not). Then you can
use the DLookup function to pull the value in that field from that
table, for a record whose criteria you specify. Note that you will
probably have to specify criteria in the DLookup expression to identify
which, of all the records in the table, holds the specific e-mail
address you want.
 
M

MSU Sptn

Oops, you are right. Here is what I am trying to do...
I have a muliselect list box (lstProgram_Manager) on the form
Frm_ProgramManager where emails are selected from the table
TblProgramManager. Once selected, I need to copy the selected emails to the
field T_Reminder_Mailing_List on the table TblCompliance. When the selected
emails are pasted to T_Reminder_Mailing_List I need them to be in a list
separated by a semicolon so that the SendObject can pull from that list to
send the emails. I put the following code into a "Save and Exit" command
button on the form Frm_ProgramManager and I get an "Object Required" error.
Any suggestions?
--------------------------
Dim varItem As Variant
Dim strList As String

With Me!lstProgram_Manager
If Me!lstProgram_Manager.MultiSelect = Null Then
TblCompliance!T_Reminder_Mailing_List = Null

Else
For Each varItem In Me!lstProgram_Manager.ItemsSelected
strList = strList & .Column(1, varItem) & ";"
Next varItem
strList = Left$(strList, Len(strList) - 1)
TblCompliance!T_Reminder_Mailing_List = strList
End If
End With
 
Top