wizcow
Registered User.
- Local time
- Yesterday, 18:14
- Joined
- Sep 22, 2001
- Messages
- 236
I can't get rid of the "No Current Record" message.
My form runs this code in the 'On Current' event to get the last stock take date.
If there has not been a stocktake done for this record I get the above error message box.
I thought the setwarnings would stop the error message but it does not.
Anyone see what I doing wrong?
Thanks
Tom
My form runs this code in the 'On Current' event to get the last stock take date.
If there has not been a stocktake done for this record I get the above error message box.
Code:
Dim db As DAO.Database 'Type of reference Tools>>References.. Microsoft DAO 3.6 (or highest)
Dim rs As DAO.Recordset 'A place for the query result to live (recordsets)
Dim strSQL As String 'A place for the current query to live
Dim lngPartNo As Long 'A place to store the part number
lngPartNo = [Forms]![Part]![ItemNo] 'get part number from a form
Dim lngStockTakeDate As Long
Dim lngLastStockTakeQty As Long
'Get the last StockTakeDate and Quantity for the part
strSQL = "SELECT TOP 1 Inventory.StockTakeDate, InventorySub.Quantity" & _
" FROM Inventory INNER JOIN InventorySub ON Inventory.InventoryID = InventorySub.InventoryID" & _
" WHERE (InventorySub.ItemNo) = " & lngPartNo & _
" ORDER BY Inventory.StockTakeDate DESC;"
'Set the database to this database and open the query results in a recordset
Set db = CurrentDb
[B]DoCmd.SetWarnings False[/B]
Set rs = db.OpenRecordset(strSQL)
[B]DoCmd.SetWarnings True[/B]
With rs
'Check to see if there has been an inventory taken
If .RecordCount > 0 Then
'Assign a place for the last StockTakeDate and Quantity to live
datStockTakeDate = rs!StockTakeDate
lngLastStockTakeQuantity = rs!Quantity
'Pass value to form
Me!LastInventoryDate = datStockTakeDate
Else
Me!LastInventoryDate = "No Data"
lngLastStockTakeQuantity = rs!Quantity
End If
End With
'Empty the strSQL recordset so you can open a new one
rs.close
I thought the setwarnings would stop the error message but it does not.
Anyone see what I doing wrong?
Thanks
Tom