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. Assigning the value from a QueryDef object...

Assigning the value from a QueryDef object...

Scheduled Pinned Locked Moved Database
questiondatabasebusinesscareer
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

    I would like to be able to assign the value from a created QueryDef object to a modifiable recordset object variable. How do I go about doing this? The Microsoft documentation does not provide any explanations. Here is the code so far:

    Private Sub ProcessHeadcountRecords()
    Dim dbsHeadcount As Database
    Dim Cnxn As ADODB.Connection
    Dim strConn As String
    Dim rstInputFile As ADODB.Recordset
    Dim cmdSQLInputFile As ADODB.Command
    Dim strSQLInputFile As String
    Dim rstHyperionMany As ADODB.Recordset
    Dim cmdSQLHyperionMany As ADODB.Command
    Dim strSQLHyperionMany As String
    Dim rstHyperionOne As ADODB.Recordset
    Dim cmdSQLHyperionOne As ADODB.Command
    Dim strSQLHyperionOne As String
    Dim qdfNew As QueryDef
    Dim strDBPath As String
    Dim strFileName As String
    Dim strMessage As String

    strDBPath = "J:\\GELCO DATABASE\\Headcount Database\\Headcount Database.mdb"
    Set dbsHeadcount = OpenDatabase(strDBPath)
    Set Cnxn = New ADODB.Connection
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0; " & \_
        "Data Source=" & strDBPath & ""
    Cnxn.Open strConn
    
    Set rstInputFile = New ADODB.Recordset
    strSQLInputFile = "SELECT \[COUNTRY\], \[TYPE\], \[BUSINESS\_UNIT\], " & \_
        "\[L\_R\_G\], \[REGION\], \[JOB\_FUNCTION\], \[ACTUAL\], \[NUMINDEX\] " & \_
        "FROM TBLINPUTFILE"
    rstInputFile.Open strSQLInputFile, Cnxn, adOpenKeyset, adLockOptimistic
    rstInputFile.MoveFirst
    
    Set rstHyperionMany = New ADODB.Recordset
    strSQLHyperionMany = "SELECT \[COUNTRY\], \[TYPE\], \[BUSINESS\_UNIT\], " & \_
        "\[L\_R\_G\], \[REGION\], \[JOB\_FUNCTION\], \[NUMFOREIGNKEY\] " & \_
        "FROM \[TBLHYPERIONMANY2\] ORDER BY \[NUMFOREIGNKEY\]"
    rstHyperionMany.Open strSQLHyperionMany, Cnxn, adOpenKeyset, adLockOptimistic
    
    strFileName = "qryPassThroughQuery"
    Do Until rstInputFile.EOF
        With dbsHeadcount
            strSQLHyperionMany = "SELECT \[COUNTRY\], \[TYPE\], " & \_
                "\[BUSINESS\_UNIT\], \[L\_R\_G\], \[REGION\], \[JOB\_FUNCTION\], \[NUMFOREIGNKEY\] " & \_
                "FROM \[TBLHYPERIONMANY2\] " & \_
                "WHERE \[COUNTRY\]='" & UCase(rstInputFile!\[COUNTRY\]) & "' " & \_
                "AND \[TYPE\]='" & UCase(rstInputFile!\[Type\]) & "' " & \_
                "AND \[BUSINESS\_UNIT\]='" & UCase(rstInputFile!\[BUSINESS\_UNIT\]) & "' " & \_
                "AND \[L\_R\_G\]='" & UCase(rstInputFile!\[L\_R\_G\]) & "' " & \_
                "AND \[REGION\]='" & UCase(rstInputFile!\[REGION\]) & "' " & \_
                "AND \[JOB\_F
    
    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