设有数据表table(a,b,c,d),创建查询A(a,[b-c] as e)。由查询A创建查询结果的窗体A(a,[b-c] as e),另创建一空窗体B(a,b,c,d)作为窗体A的数据联动窗口。
创建过程:在窗体A中字段a的“单击事件”创建代码:
Private Sub a_Click()
DoCmd.OpenForm "窗体B"
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Set Forms! B.Recordset = Me.Recordset
Forms! B.a = Me.Recordset("a")
dim strSql as string
strSql="select * from table where a = '" & Forms! B.a & "'" -----去掉where句后错误消灭 rs.Open strSql, CurrentProject.Connection, adOpenDynamic, adLockOptimistic ------这句报错:[attach]50390[/attach]