× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



We have multi-member files and we're on v5r4 and QZRCSRVS and QZDASOINIT run in QUSRWRK. My excel VBA pulls DB2 data in from the first member with an SQL SELECT statement. I want to pull the data from a different member. When the program runs, the OVRDBF runs in QZRCSRVS and the SQL SELECT runs in QZDASOINIT.

How do I make the OVRDBF run in the QZDASOINIT job and not the QSRCSRVS job? Is this possible? Google shows posts, all pretty old, indicating it is possible to do an OVRDBF. Even the book I got the VBA code from says it's possible although I didn't see a coded example. I know that creating an ALIAS works but, for reasons I won't go into, I don't want to go that route.

Here's the VBA code. (most from i5/OS and MS Office Integration Handbook, 3rd edition, by Chris Peters and Brian Singleton)

Sub StuffCells(sSQL As String, sSheetName As String, sCell As String, sOVRDBF As String)
Dim colCount As Integer
Dim colIdx As Integer
Dim strLength As Double

Set cnMYSQLCMD.ActiveConnection = cnMYiSeries

If sOVRDBF <> "" Then
'execute the OVRDBF command
strLength = Len(sOVRDBF)
With cnMYSQLCMD
.CommandText = "{{CALL QSYS.QCMDEXC ('" & sOVRDBF & "' " & Format(strLength, "0000000000") & ".00000)}}"
.CommandType = adCmdText
.Execute
End With
End If

cnMYSQLCMD.CommandText = sSQL
'execute the SQL query
Set rsMYRECSET = cnMYSQLCMD.Execute()

Worksheets(sSheetName).Activate
Range(sCell).Select

'get all rows from the recordset
Do While Not rsMYRECSET.EOF
colCount = rsMYRECSET.Fields.Count

For colIdx = 0 To colCount - 1
ActiveCell.Value = rsMYRECSET.Fields(colIdx).Value
ActiveCell.Offset(0, 1).Activate
Next colIdx
' Move back to the beginning
ActiveCell.Offset(1, -colCount).Activate

rsMYRECSET.MoveNext
Loop
Set rsMYRECSET = Nothing
Set cnMYSQLCMD = Nothing

End Sub

Thanks,
Reggie Acosta


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.