Results 1 to 2 of 2
  1. #1
    treyxman is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    15

    help on DLookup code!

    hello, i'm new to this site and I guess you could say im not an expert at access however I know a little bit of vb from past excel work and some access work.



    I've been trying to write a little code that will be attached to a command button that will send out an email to a person that was selected in a combo box on the form where the button is.

    My problem is that I have a dlookup statement in the code and it is spitting out an error that says "you canceled the previous operation." I've been looking all over the internet trying to solve this however it's just not working out.

    I have all the correct spelling and I made sure they are referencing the correct tables and everything. any help would be much appreciated! thanks

    Private Sub Send_To_AE_Click()
    On Error GoTo Err_Send_To_AE_Click

    Dim stDocName As String
    Dim DLookupResults As String

    DLookupResults = DLookup("[EMail]", "[EmailAddresses]", "[Inside_AE]='" & Forms![Main Form]![coboxInsideAE] & "'")

    stDocName = "Issue Report"
    DoCmd.SendObject acReport, stDocName, acFormatSNP, DLookupResults, , , , "Order Issue Report", "body of email"

    Exit_Send_To_AE_Click:
    Exit Sub

    Err_Send_To_AE_Click:
    MsgBox Err.Description
    Resume Exit_Send_To_AE_Click
    Set MyOutlook = Nothing

    End Sub

  2. #2
    treyxman is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    15
    to clarify that up, im trying to use the dlookup to lookup an email address that i have stored in the EmailAddresses table based on what name is in the coboxInsideAE combo box

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Vba dlookup code help!
    By amsmakkah in forum Programming
    Replies: 1
    Last Post: 07-19-2011, 09:38 AM
  2. Word code in Access - How to modify my current code
    By Alexandre Cote in forum Programming
    Replies: 0
    Last Post: 11-15-2010, 08:26 AM
  3. Code in combobox, code in text box
    By float in forum Forms
    Replies: 3
    Last Post: 09-29-2010, 07:12 AM
  4. DLookup code not working
    By lukekelly in forum Programming
    Replies: 9
    Last Post: 06-15-2010, 06:08 AM
  5. Dlookup
    By janjan_376 in forum Access
    Replies: 20
    Last Post: 07-07-2009, 07:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums