Connecting Tech Pros Worldwide Forums | Help | Site Map

Scripting a listing of items from a table's column

MitchR's Avatar
Member
 
Join Date: Oct 2006
Location: Greenville SC
Posts: 52
#1: Nov 27 '06
I am trying to Script a listing of items from a table. These items would show in an email generated by the script. The email generation is good ... My question is how to script the listing of items in the email. My Table is Called Term. My Listing is from the User.

PEB's Avatar
PEB PEB is offline
Expert
 
Join Date: Aug 2006
Location: Bulgaria
Posts: 1,380
#2: Nov 27 '06

re: Scripting a listing of items from a table's column


Quote:

Originally Posted by MitchR

I am trying to Script a listing of items from a table. These items would show in an email generated by the script. The email generation is good ... My question is how to script the listing of items in the email. My Table is Called Term. My Listing is from the User.

What is it??? Scripting a listing of items??? Can u give an exemple?
MitchR's Avatar
Member
 
Join Date: Oct 2006
Location: Greenville SC
Posts: 52
#3: Nov 27 '06

re: Scripting a listing of items from a table's column


Private Sub Command0_Click()
Dim rec As Long
Dim stWhere As String '-- Criteria for DLookup
Dim varTo As Variant '-- Address for SendObject
Dim stText As String '-- E-mail text
Dim RecDate As Variant '-- Rec date for e-mail text
Dim stSubject As String '-- Subject line of e-mail
Dim varserial_num As Variant '-- The ticket ID from form
Dim varWho As Variant '-- Reference to tblUsers
Dim strSQL As String '-- Create SQL update statement
Dim myDate As Variant '-- Current Date
Dim varmgr As Variant
Dim errLoop As Error
Dim Err_EMail As Error
On Error GoTo Err_Command0_Click
myDate = Date
rec = CurrentRecord
Dim db As Database
Dim rs As Recordset
Dim mailList As String
varWho = Email
' varmgr = manager_ee
' This Code was Generated by ikon1\mrettberg
If IsNull(varWho) Or varWho = "" Then 'IsNull variable is null it evaluates to True the Or varWho = "" covers an empty string
MsgBox "Please Enter A Valid E-Mail Address Prior To Attempting Notification", , "Incomplete Information"
Exit Sub
End If
varserial_num = Serial_num
RecDate = Date
'DLookup to Term Database for End User Name
' varTo = DLookup("[end user]", "Term", "[serial_num] = [Forms]![term_sub]![serial_num]")
' varUser = DLookup("[User]", "Term", "[serial_num] = [Forms]![Term_sub]![serial_num]")
stSubject = "Return of Computer Assets from Termination of " & [User]
stText = "Good Day to You: " & [SUPERVISOR_NAME] & vbCrLf & vbCrLf & _
"This letter is to inform you that we have received termination notice of " & [User] & _
" on " & [Act_Term_date] & " and we are inquiring as to the return of his or her computer equipment." & vbCrLf & vbCrLf & _
"We have a couple of loose ends to tie up and then we will be all set." & vbCrLf & vbCrLf & _
"1.I need for you to check the bag and verify all accessories are present" & vbCrLf & _
"2.I need for you to place the laptop inside the laptop bag. Place the bag into a box with at least 2 inches of packing material on all 6 sides (top, bottom, and all four sides) and ship it overnight ... with an insured value of $3500 to the following address: " & RecDate & vbCrLf & vbCrLf & _
"Asset ID: " & Asset_ID & vbCrLf & _
"Asset Type: " & Asset_Type & vbCrLf & _
"Serial #: " & Serial_num & vbCrLf & vbCrLf & _
"Mitch Rettberg" & vbCrLf & _
"10 Patewood Drive" & vbCrLf & _
"Suite 300 Building 6" & vbCrLf & _
"Greenville, SC 29615" & vbCrLf & vbCrLf & vbCrLf & vbCrLf & _
"Send me an email with the Property of IKON Number & Tracking Number at mrettberg@ikon.com" & vbCrLf & _
"That is all" & vbCrLf & vbCrLf & _
LstBox = (User) & _
"Thank you and have a Great Day"
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#4: Nov 27 '06

re: Scripting a listing of items from a table's column


What do you want to include in your e-mail?
Field names?
Data held in records?
If it's data then it would be query based and if it's the structure you'd need to get that from looping through your table structure in VBA.
MitchR's Avatar
Member
 
Join Date: Oct 2006
Location: Greenville SC
Posts: 52
#5: Nov 27 '06

re: Scripting a listing of items from a table's column


Quote:

Originally Posted by NeoPa

What do you want to include in your e-mail?
Field names?
Data held in records?
If it's data then it would be query based and if it's the structure you'd need to get that from looping through your table structure in VBA.

I want my email to include all items listed under the column User in my Terms. In a manner similar to a combo box listing all items in a column
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#6: Nov 27 '06

re: Scripting a listing of items from a table's column


If your table is called Terms and the field required is User then you need to get your data from a query like
Expand|Select|Wrap|Line Numbers
  1. SELECT [User]
  2. FROM [Terms]
I don't know how you get that data into the e-mail - not my area - but that's the data you want anyway.
MitchR's Avatar
Member
 
Join Date: Oct 2006
Location: Greenville SC
Posts: 52
#7: Dec 11 '06

re: Scripting a listing of items from a table's column


Thank you NeoPa .... I was able to start the ball rolling with your help and with some additional guidance was able to resolve my issue: Here is the answer that resolved the problem:

Scripting the contents of a column into a generated email
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#8: Dec 11 '06

re: Scripting a listing of items from a table's column


I'm pleased I could help.
Thanks for posting the answer link btw.
Reply