I'm using Access 2000 (and also 2003 with same result) in a Windows XP Professional environment on a peer-to-peer network. Files in this system are relatively small. There are about 1,200 rows in the item/warehouse table, about 200 order headers, and about 2000 order detail rows.
I have a form with a sub-form in the detail of the main form. The sub-form is a continuous line display (not single item); In the heading I am getting a customer's order heading information, and in the subform I am listing all of the line items for that order.
Each line in the subform has a text box for inventory item number, quantity ordered, quantity shipped, on hand quantity, and on order quantity (all open orders combined).
If the order quantity for that item exceeds the (on hand - on order) then there are not enough available for that order and I use conditional formatting to turn the background of the on hand text box yellow.
The problem is, sometimes this form is VERY slow to complete. The on hand and on order boxes remain empty, filling down the screen slowly. And oddly, if you do an ALT-TAB to switch out of the screen, and ALT-TAB back immediately, then suddenly all the text boxes are filled in. Or, if you wave your mouse over an empty text box, the value for that text box will appear.
The on-hand quantity is not a single field, there can be on hand in more than one warehouse.Here is the code to return the on hand value for an item
The code to get the on order quantity comes from a query, and it is like this
What's going on and how to I correct it?
Thanks,
Jim
I have a form with a sub-form in the detail of the main form. The sub-form is a continuous line display (not single item); In the heading I am getting a customer's order heading information, and in the subform I am listing all of the line items for that order.
Each line in the subform has a text box for inventory item number, quantity ordered, quantity shipped, on hand quantity, and on order quantity (all open orders combined).
If the order quantity for that item exceeds the (on hand - on order) then there are not enough available for that order and I use conditional formatting to turn the background of the on hand text box yellow.
The problem is, sometimes this form is VERY slow to complete. The on hand and on order boxes remain empty, filling down the screen slowly. And oddly, if you do an ALT-TAB to switch out of the screen, and ALT-TAB back immediately, then suddenly all the text boxes are filled in. Or, if you wave your mouse over an empty text box, the value for that text box will appear.
The on-hand quantity is not a single field, there can be on hand in more than one warehouse.Here is the code to return the on hand value for an item
Code:
Public Function CalcOnHand(ItemNbr As String) As Long
Dim db As Database
Dim rs As DAO.Recordset
Dim qd As QueryDef
Dim Sql As String
Dim strFind As String
Dim Onhandqty, Counter As Integer
Counter = 0
Set db = CurrentDb
Set rs = db.OpenRecordset("ItemWarehouse")
Onhandqty = 0
On Error GoTo Loopend
rs.MoveFirst
strFind = "Item='" & CStr(ItemNbr) & "'"
rs.FindFirst (strFind) ' first occurrence of this item in itemwh file
LoopItems:
While (Not (rs.EOF))
If rs.NoMatch Then GoTo Loopend
If rs![Item] <> ItemNbr Then GoTo NextItem
' If rs![Warehouse] <> "9301" And rs![Warehouse] <> "3405" Then GoTo NextItem
If rs![Warehouse] = "PCR" Then GoTo NextItem
Counter = Counter + 1
Onhandqty = Onhandqty + rs![OnHand]
If Counter > 1 Then GoTo Loopend 'don't bother looking after we found both warehouses
NextItem:
rs.FindNext (strFind)
'rs.MoveNext
Wend
'GoTo LoopItems
Loopend:
CalcOnHand = Onhandqty
rs.Close
Set rs = Nothing
End Function
Code:
SELECT tbl_Orders.OHCustomerID, tbl_Orders.OHOrderDate, tbl_Orders.OHOrderNbr, tbl_Orders.OHPONumber, tbl_Orders.OHCasesPerPallet, tbl_Orders.OHMemo, tbl_Orders.OHStatus, tbl_Orders.OHCarrier, tbl_Orders.OHTotalWeight, tbl_Orders.OHPalletCount, tbl_Orders.OHShipDate, tbl_Orders.OHBOL, tbl_Orders.OHInvoice, tbl_Orders.OHTerms, tbl_Orders.OHCHSequence, tbl_Orders.OHCases, tbl_Orders.OHCartons, tbl_Orders.OHCigarettes, tbl_Orders.OHDiscPct, tbl_Orders.OHDueDate, tbl_Orders.OHMessage, tbl_Orders.OHFreightCharge, tbl_Orders.OHMiscCharge FROM tbl_Orders ORDER BY tbl_Orders.OHOrderDate DESC , tbl_Orders.OHOrderNbr DESC;
Thanks,
Jim
Comment