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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamically create variable at run time

Status
Not open for further replies.

ktucci

Programmer
Apr 23, 2001
146
US
bare with me here..i am no vb expert...

i need to dynamically create the variables in call to sendmail at run time...eg: email addr, accountno, lastname, frstname...there can be 1 variable or 10 it can be different each time..and the sendmail sub must be built accordingly each time


Private Sub Start_Click()
Dim SQLString As String
SQLString = SQL_ScriptString
Set rs = New ADODB.Recordset
rs.Open SQLString, cn, adOpenStatic, adLockPessimistic
rs.MoveLast
SendMail rs("email_addr"), rs("accountno"), rs("lastname"), rs("frstname")
.
.
.
End Sub
-
----------------------------------------------------------
-
Private Sub SendMail(stremail_addr$, straccountno$, strlastname$, strfrstname$)


thanks in advance
 
Can you not pass a dictionary around?

dict("EmailAddress") = whatever
SendMail(dict)

Private Sub SendMail(dict as Scripting.Dictionary)
...
End Sub

Chaz
 
bare with me here..
I'm not really sure from your post what you want to do, but I'm guessing that you want to run the sub "SendMail" one or more times, and the DATA is from the records in "rs", which changes from one record to the next.



Private Sub Start_Click()
Dim SQLString As String
SQLString = SQL_ScriptString
Set rs = New ADODB.Recordset
rs.Open SQLString, cn, adOpenStatic, adLockPessimistic
Do While Not rs.EOF And Not rs.BOF
SendMail rs("email_addr"), rs("accountno"), rs("lastname"), rs("frstname")
.
.
rs.MoveNext
Loop
Tim

Remember the KISS principle:
Keep It Simple, Stupid!
 
SendMail rs("email_addr"), rs("accountno"), rs("lastname"), rs("frstname")

this part can contains different and more or less fields each time...i have field names in an ini file that i want the associated records to be passed in the sendmail call

the the sendmail sub would need to dynamically alter itself to accept

Private Sub SendMail(stremail_addr$, straccountno$, strlastname$, strfrstname$)

so this combination of fields i need to be retieved from an ini file (that part is fine)...i have the strings of teh field names i want to use i just can not dynamically alter the sendmail sub or the call to it
 
How about telling me what your trying to do, and why, in plain English...forget the code refs. As in:
I have to send mail. Some of the.....some don't.
What I want to do is.............
(or whatever) Tim

Remember the KISS principle:
Keep It Simple, Stupid!
 
i trying to query a table a rerieve a recordset (usualy 2000-30000 records) and the # of fields and field names can change each time i run this. after retrievingg the recordset i want to loop through record by record and each record i want to pass designated fields to a mail object. the fields i pass can change be different each time i run this. the mail object builds the message, does a merge to a html for customizing the contents with records from the record set, adds the recipient address from record set, and then sends the message to a folder.

thanks for your help

keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top