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