这个的基本功能是当你登录系统并在加载主菜单时,它应该显示一条消息,如果某些产品已达到临界水平,当你按是,它应该重定向到表格它显示了一个详细的视图。
在这种情况下,手头的数量是“QTY”,临界水平是“ROQ”(tblProduct中的字段名称)
Dim Alert As Integer
Dim rsAlert As New Adodb.Recordset
rsAlert.Open "select * from tblproduct , CurrentProject.Connection"
Alert = DCount("[qty]", "[tblProduct]", " [ROQ] <= Qty and =0")
If Alert = 0 Then
Exit Sub
Else
If MsgBox("This/These " & Alert & " product/products have reached their critical levels" & _
vbCrLf & vbCrLf & "Would you like to see these now?", _
vbYesNo, "Alert...") = vbYes Then
DoCmd.Minimize
DoCmd.OpenForm "frmAlerts", acNormal
Else
Exit Sub
End If
End If
End Sub
我得到的错误是当加载我的菜单菜单时,它没有显示处于临界水平的产品数量!如果有人可以帮助它将是一个很好的帮助!
这已在Microsoft Access中完成。
答案 0 :(得分:0)
继我的评论之后,这是行不通的。创建一个列表框并用库存短缺填充它,如下所示;
Dim rsAlert As Recordset
Dim sSql As String
sSql = "SELECT ProductID, Description, OtherFields, GoHere FROM tblproduct WHERE ROQ >= QTY AND ROQ > 0"
Set rsAlert = CurrentDb.OpenRecordset(sSql, dbOpenSnapshot)
If Not rsAlert.EOF Then 'There are records (shortages) so unhide and poulate the list box (called lstShortageListBox)
Me.lstShortageListBox.Visible = True
Me.lstShortageListBox.RowSource = sSql
Else
Me.lstShortageListBox.Visible = False
End If
' Tidy Up
rsAlert.Close
Set rsAlert = Nothing
显然要确保记录集标准是正确的 - 我已经对这一点做了一些猜测。