|
6#
楼主 |
发表于 2016-8-12 11:04:54
|
只看该作者
本帖最后由 fatmingli 于 2016-8-12 11:15 编辑
Private Sub Text2_Change()
Me.Requery
End Sub
Private Sub 查询_Click()
MsgBox "累计数量是" & Me.Text3 & ""
End Sub
你通过2个事件分了两个过程,那肯定没问题,请问如何在一个按钮的单击事件完成呢,因为我需要这样做,下面是我的部分代码
Dim AA As String
Me.Text2.RowSource = "SELECT DISTINCT 名称 FROM "
DoCmd.SetWarnings False
Dim rs As DAO.Recordset 'SQL语句的值不能直接赋值给变量的,要引用ADO 或DAO,
Set rs = CurrentDb.OpenRecordset("select count(*) as AA from (select d
AA = rs("AA")
For K = 0 To AA - 1
Me.Text2 = Me.[Text2].[ItemData](K) '更改数据Text2的值
Me.Requery '刷新数据,目的同时刷新Text3的值,但实际效果是来不及计算,Text3为空
N1 = DCount("[剩余 >0") 'N1表示卖空次数
If N1 = 0 Then '=0 表示从没卖空过
'Text13 = "A1=" & Text4 & ",B1=;"
P = Text3 实际效果是Text3来不及计算,Text3为空,导致赋值给变量P时也为空
Text13 = "A1=" & Text4 & ",B1=,P1=" & P & ""
.……
DoCmd.RunSQL "insert into Text13
.……
Next K |
|