Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Dim lRS as DAO.RecordSet
Set lRS = CurrentDb.OpenRecordset(strSQL)
If lRS.BOF and lRS.EOF then
' there is no data returned by the query
.
.
.
Else
' data has been returned
.
.
.
End If
dim intUnitsInStock as Integer
intUnitsInStock = DLookup("[UnitsInStock]", "[tblproducts]", "[ProductID] = " & product_id)
If IsNull(intUnitsInStock) Then
'There is no match
.
.
.
Else
'There is a match
.
.
.
End If
[b]Function product_reorder(product_id As Integer)[/b]
Dim onhand As Variant
Dim reorderlevel As Variant
Dim onorder As Variant
strSQL as string
onhand = DLookup("[UnitsInStock]", "[tblproducts]", "[ProductID] = " & product_id)
reorderlevel = DLookup("[ReorderLevel]", "[tblproducts]", "[ProductID] = " & product_id)
rquantity = DLookup("[OrderAmount]", "[tblproducts]", "[ProductID] = " & product_id)
onorder = DLookup("[UnitsOnOrder]", "[tblproducts]", "[ProductID] = " & product_id)
If (onhand > reorderlevel) Then
MsgBox "1"
End
Else
'UPDATE tblproducts
MsgBox "2"
strSQL = "update tblproducts set UnitsOnOrder = " & rquantity & " where ProductID = " & prodid & " "
DoCmd.RunSQL strSQL
End If
End Function
Function product_reorder(product_id As Integer)
Dim onhand As Variant
Dim ReOrderLevel As Variant
Dim onorder As Variant
[COLOR=red]Dim[/color] strSQL As String
onhand = DLookup("[UnitsInStock]", "[tblproducts]", "[ProductID] = " & product_id)
ReOrderLevel = DLookup("[ReorderLevel]", "[tblproducts]", "[ProductID] = " & product_id)
rquantity = DLookup("[OrderAmount]", "[tblproducts]", "[ProductID] = " & product_id)
onorder = DLookup("[UnitsOnOrder]", "[tblproducts]", "[ProductID] = " & product_id)
If (onhand > ReOrderLevel) Then
MsgBox "1"
End
Else
'UPDATE tblproducts
MsgBox "2"
strSQL = "update tblproducts set UnitsOnOrder = " & rquantity & " where ProductID = " & [COLOR=red]product_id [/color]& " "
DoCmd.RunSQL strSQL
End If
End Function
Function product_reorder(product_id As Integer)
Dim rst As New ADODB.Recordset
Dim strSQL As String
Dim onhand As Variant
Dim reorderlevel As Variant
Dim orderquantity As Variant
Dim onorder As Variant
'query for recordset
strSQL = "SELECT UnitsInStock, ReorderLevel, OrderAmount, UnitsOnOrder "
strSQL = strSQL + "FROM tblproducts "
strSQL = strSQL + "WHERE ProductID = " & product_id
'create recordset
rst.Open strSQL, CurrentProject.Connection
'assign field values to vars
onhand = rst.Fields("UnitsInStock").Value
reorderlevel = rst.Fields("ReorderLevel").Value
orderquantity = rst.Fields("OrderAmount").Value
onorder = rst.Fields("UnitsOnOrder").Value
If (rst!UnitsOnOrder > 0) Then 'has stock already been ordered
rst.Close
MsgBox "Stock already on order"
End
End If
If ((rst!UnitsInStock) > (rst!reorderlevel)) Then 'has reorder level been reached
MsgBox onhand
rst.Close
End
Else 'reorder level reached UPDATE tblproducts and return
rst.Close
strSQL = "update tblproducts set UnitsOnOrder = " & orderquantity & " where ProductID = " & product_id & " "
DoCmd.RunSQL strSQL
MsgBox strSQL
End If
Set rst = Nothing
End Function