0

在一个 html 页面中,我创建了一个子窗口来执行一些过滤(选择打印机,以及要在报告上打印哪些部分)。为了在子窗口中显示部件选择,我需要从父窗口调用 GetParts 函数并将记录集返回给子窗口。这里有一些代码可以提供帮助:

从子窗口->

Sub LoadParts(frmRptFilter)
Dim sql
Dim oParts
Set oParts = CreateObject("ADODB.Recordset")
oParts.Fields.Append "Part", adBSTR , 30
oParts.Open
oParts = window.opener.GetParts(oParts) 'Since oParts was passed as a parameter I did not believe this to be necessary, but when it didn't work as expected I tried returning it this way....didn't work either
'more code follows

在父窗口中 ->

Function GetParts(oParts)
Dim sql

sql = "SELECT Job.Part_Number FROM Job RIGHT JOIN Packlist_Detail ON Packlist_Detail.Job = Job.Job "_
    & "WHERE Packlist_Detail.Packlist LIKE '" & sPL & "'"

CloseRS(oRS)
oRS.Open sql, oConn, adOpenStatic, adLockReadOnly

oRS.MoveFirst

If Not (oRS.BOF AND oRS.EOF) Then
    Do while not oRS.EOF
        oParts.AddNew
        oParts("Part").Value = oRS(0)
        oParts.Update
        oRS.MoveNext
    Loop 
End If

'GetParts = oParts 'Since oParts was passed as a parameter I did not believe this to be necessary, but when it didn't work as expected I tried returning it this way....didn't work either
End Function

我为一个软件编写报告,该软件需要我创建包含水晶报告对象的过滤器和报告 html 页面。我编写这些报告的软件限制了我在数据库连接等方面的能力。所以我不得不这样。

因此,我验证了父窗口中的 oParts 已正确填充。它做了什么!我只是无法将它填充到我的子窗口中。所以问题是,我如何在子窗口中取回一个值?

4

2 回答 2

1

试试这个
子窗口


Set oParts = window.opener.GetParts(oParts)

父窗口


Set GetParts = oParts
于 2009-04-16T17:34:22.773 回答
0

测试仪101:

尝试您所说的在父函数中出现错误:Object required 'oParts'

看到这一点,我在其中定义了 oParts 记录集:

Set oParts = CreateObject("ADODB.Recordset")
oParts.Fields.Append "Part", adBSTR , 30
oParts.Open

现在一切都很棒。

所以这个问题的真正答案是Tester101的答案加上在父函数中返回子窗口的记录集的定义。

谢谢Tester101!!!!

于 2009-04-16T18:39:25.987 回答