标题: 请大家帮忙看一下,这个程序哪里错了 [打印本页] 作者: Haoxu123 时间: 2007-9-13 10:12 标题: 请大家帮忙看一下,这个程序哪里错了 我的设想是这样的,在客户名称框中输入相关的客户名称,单击"客户查询"按键,查询"打印查询"表,把符合条件的"销售品种"中的产品的数量、总价显示在窗体中
Private Sub Command14_Click()
On Error GoTo Err_Command14_Click
Dim i As Integer
Dim STemp As String
Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset
STemp = "Select * Form 打印查询"
Rs.Open STemp, CurrentProject.Connection, adOpenKeyset, adLockBatchOptimistic
Num = 0
For i = 1 To Rs.RecordCount
If Rs("客户名称") = Me![客户名称] Then
If Me![销售品种] = Me![内酯豆腐] Then
Me![数量] = Me![数量]
Me![总价] = Me![总价]
If Me![销售品种] = Me![日本豆腐] Then
Me![数量] = Me![数量]
Me![总价] = Me![总价]
If Me![销售品种] = Me![板豆腐] Then
Me![数量] = Me![数量]
Me![总价] = Me![总价]
End If
Rs.movNetxt
End If
Rs.movNetxt
End If
Rs.movNetxt
Nexit i
Exit_Command14_Click:
Exit Sub
Er_Command_Click:
MsgBox Err.Description
Rsume Exit_Command14_Click
End Sub作者: hi-wzj 时间: 2007-9-13 10:19
STemp = "Select * Form 打印查询"
在此代码中增加where 的限定条件,以及GROUP BY 的汇总条件,后面就很好完成了。作者: tz-chf 时间: 2007-9-13 11:41
找到就该退出for,不必再找下去了。作者: andymark 时间: 2007-9-13 12:00
应该加上WHERE 条件语句作者: Haoxu123 时间: 2007-9-13 15:23
具体该怎么写呢作者: Haoxu123 时间: 2007-9-14 08:45
这里不需要汇总的作者: Haoxu123 时间: 2007-9-14 09:39
Private Sub Command14_Click()
On Error GoTo Err_Command14_Click
Dim i As Integer
Dim STemp As String
Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset
STemp = "Select * From 打印查询"
Rs.Open STemp, CurrentProject.Connection, adOpenKeyset, adLockBatchOptimistic
For i = 1 To Rs.RecordCount
If Rs("客户名称") = Me![客户名称] Then
If Me![销售品种] = Me![内酯豆腐] Then
Me![数量01] = Me![数量]
Me![总价01] = Me![总价]
ElseIf Me![销售品种] = Me![日本豆腐(120g)] Then
Me![数量02] = Me![数量]
Me![总价02] = Me![总价]
ElseIf Me![销售品种] = Me![板豆腐] Then
Me![数量03] = Me![数量]
Me![总价03] = Me![总价]
End If
End If
Next i
Exit_Command14_Click:
Exit Sub
Err_Command14_Click:
MsgBox Err.Description
Resume Exit_Command14_Click
End Sub
为什么会提示"至少一个参数没有被指定"作者: hi-wzj 时间: 2007-9-14 10:20
如果一定要这样不带条件自己去汇总的话,请设置断点后单步运行,看问题出在哪个代码上.作者: Haoxu123 时间: 2007-9-14 11:27
单个条件执行还是一样的提示,能帮我看一下这个例子吗,谢谢了!作者: hi-wzj 时间: 2007-9-14 15:23
错的地方不少,附件包含了两中解决方法,自己去看看。作者: Haoxu123 时间: 2007-9-14 16:19
非常感谢谢版主的帮助,谢谢!