Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. DoCmd.SendObject object assistance needed... [modified]

DoCmd.SendObject object assistance needed... [modified]

Scheduled Pinned Locked Moved Database
databasesysadminhelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    new_phoenix
    wrote on last edited by
    #1

    Hi, guys. I really need some assistance with the DoCmd.SendObject object in VBA in Microsoft Access. It appears that I am only limited to specific ObjectTypes that does not include an approach to do so dynamically in code. It appears in code that there are fewer options than there are with the implementation of macros which also permit "Stored Procedures" and "Server Views". Can I send the results of strSQLFQT to the SendObject? You see, I need to loop through two tables at the same time, and for every occurrence of the DISTINCT item in rstMRL there could be many records in rstFQT. I would like to send only the relevent records from rstFQT to each person in rstMRL. Can someone kindly tell me where I am going wrong. The code I have so far is as follows:

    Option Compare Database
    Dim db As New DAO.DBEngine
    Dim rec As Recordset

    Function Email_New()
    On Error GoTo Email_New_Err

    DoCmd.OpenQuery "Final Query Test 2", acViewNormal, acReadOnly
    DoCmd.GoToRecord acQuery, "Final Query Test 2", acFirst
    Call SendEmails
    

    Email_New_Exit:
    Exit Function

    Email_New_Err:
    MsgBox Error$
    Resume Email_New_Exit

    End Function

    Function SendEmails()
    On Error GoTo ErrorHandler

    Dim Cnxn As ADODB.Connection
    Dim strConn As String
    Dim rstMRL As ADODB.Recordset
    Dim cmdSQLMRL As ADODB.Command
    Dim strSQLMRL As String
    Dim rstFQT As ADODB.Recordset
    Dim cmdSQLFQT As ADODB.Command
    Dim strSQLFQT As String
    Dim strHoldRecString As String
    Dim strMessage As String
      
    Set Cnxn = New ADODB.Connection
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=J:\\GELCO DATABASE\\Gelco\_USA.mdb;"
    Cnxn.Open strConn
    
    Set cmdSQLMRL = New ADODB.Command
    Set cmdSQLMRL.ActiveConnection = Cnxn
    strSQLMRL = "Select \[Rep Number\], \[Rep ID\], \[Email Address\] " & \_
        "FROM \[Master Rep List Test\] ORDER BY \[Rep Number\]"
    cmdSQLMRL.CommandType = adCmdUnknown
    cmdSQLMRL.CommandText = strSQLMRL
    Set rstMRL = cmdSQLMRL.Execute()
    rstMRL.MoveFirst
    strHoldRecString = rstMRL!\[Rep Number\]
    
    Set cmdSQLFQT = New ADODB.Command
    Set cmdSQLFQT.ActiveConnection = Cnxn
    
    ' Attempted Dynamic SQL here...
    strSQLFQT = "SELECT \[Confirmation #\], \[Rep Name\], " & \_
        "\[Report #\], \[Email Address\], \[Days Aged\] " & \_
        "FROM \[Final Query Test 2\] WHERE \[Days Aged\] > 30 " & \_
        "AND \[Rep ID2\] = '" & strHoldRecString & "'"
    
    MsgBox strSQLFQT   ' Shows the results
    
    cmdSQLF
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups