• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1168
  • Last Modified:

VBA: Get text from combo box

I have a form and am using the below code to try to send the text of a combo box using SMTP.  The email works, but it comes out like so:

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\EMAIL\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Maintenance Request

Submitted By: 3783
Time Requested: 3/17/2007 5:12:35 PM
Work Type: 3
Priority: 1
Location: Bay-A
Asset: BP-002
Problem Description:  vvvvv
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Now, this is basically what I want, but if you can tell, for example on the "Requestor" it shows a number.  In my combo, this is actually text, but the combo is bound to a number so I can understand why it does this.  Below is the code I have been trying to just use the actual TEXT of the combo versus its value with no success.  I have tried "me.reqid.text"  and "reqid.text" amoung other things with no success.

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\VBA CODE\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

 Dim objCDOMail As Object
      Set objCDOMail = CreateObject("CDO.Message")
    objCDOMail.To = "--SOME EMAIL--"
    objCDOMail.FROM = "--SOME EMAIL--"
     objCDOMail.Subject = "MAINTENANCE REQUEST"
   objCDOMail.TextBody = "Maintenance Request" & vbCrLf & vbCrLf & "Submitted By: " & Me.reqid & vbCrLf & "Time Requested: " & Me.DateRec & vbCrLf & "Work Type: " & Me.WorkType & vbCrLf & "Priority: " & Me.WorkPriority & vbCrLf & "Location: " & Me.LocationNo & vbCrLf & "Asset: " & Me.AssetNo & vbCrLf & vbCrLf & "Problem Description: " & Me.ProbDesc    
    objCDOMail.configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objCDOMail.configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ""
    objCDOMail.configuration.Fields.Update      
    objCDOMail.Send
    Set objCDOMail = Nothing
0
chrisryhal
Asked:
chrisryhal
  • 2
1 Solution
 
FrivolousSamCommented:
Why not look up the name using DLookup:

DLookup("[Name]", Requestors, [reqid] = " & Me.reqid)
0
 
chrisryhalAuthor Commented:
I don't understand what you are refering too.  Could you please provide an example?  If you need the table name, its called "Employee's".
0
 
stevbeCommented:
If you are displaying the name in the combobox (and I bet you are) you need to determine which column it is in ... colyumns are 0 based so if the first (and bound column) is the ID and the second column is the name ...

 objCDOMail.From = Me.cboRequestor.Column(1)

Steve
0
 
chrisryhalAuthor Commented:
stevbe,

That column thing is what I needed.  Thank you VERY much!!!!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now