Solved

VBA: Get text from combo box

Posted on 2007-03-18
4
1,160 Views
Last Modified: 2013-11-27
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
Comment
Question by:chrisryhal
  • 2
4 Comments
 
LVL 6

Expert Comment

by:FrivolousSam
ID: 18743616
Why not look up the name using DLookup:

DLookup("[Name]", Requestors, [reqid] = " & Me.reqid)
0
 
LVL 2

Author Comment

by:chrisryhal
ID: 18747269
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
 
LVL 39

Accepted Solution

by:
stevbe earned 500 total points
ID: 18747852
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
 
LVL 2

Author Comment

by:chrisryhal
ID: 18897465
stevbe,

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

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question