Hello, I seem to have a complex problem and can't sort it out.
I'm trying to use a query to pull info from the last record in a table but its acting very glitchy and for the life of me I can't even find a pattern to what's causing it, I have a theory though.
Ok the db is quite complex and is for inventory control. I have a table called "Orders" where all orders get placed and the order details go to a table called "Inventory" (bad choice of name) which are linked together and works flawlessly.
In the "orders" table I'm trying to pull the last record for each vendor showing the "bin" they last used. In the query I have just the "orders" table in the query using the fields "VendorID" and "Bin". In the query I've used the criteria "DLast("Bin","Orders","VendorID=" & [VendorID])" and using grouping I've used Last and both give the same result.
I add records to the table via 2 methods, a regular form and on that form I add records using SQL insert. Depending what a user does on the form it might add a single record using just the form or it may trigger 2 SQL insert statements which adds 2 extra records to the table, so when the user is done on the form 3 new records were created and that is also working flawlessly.
It appears that if the last 2 records have the same VendorID and one was inserted via "SQL insert" and the other via the form it chooses the SQL insert record even though it comes before the record that was inserted via the form. (I hope that makes sense)
Its seems if all records go in via the form the query always has the right result and if all records go in via SQL insert the query has the right results but when records are added via both methods it seems to have glitches, however that could be all wrong because its done this from the very beginning I think before I used SQL insert except in less frequency. I got help on the forum once and thought I had it sorted out but the problem still exists.
The worst is I don't even know if this is whats causing it but its the best pattern I can come up with.
If I add just the field "OrderID" from the table "orders" in the query it still doesn't pull the last orderID, it acts the same and gets stuck on the same record for.
The table "inventory" which has all the order details also has the same problem. For the heck of it I thought I would make a query to use just the "inventory" table and only the "inventoryID" field and pull the last record but its getting stuck at ID# 721. There's a gap for ID's it starts again at 870 - 972 however the query doesn't see any of those records when using DLast, if its a normal query with no grouping it shows all records.
I thought it was the gap between ID's at first because it was stuck on a gap in the orders table as well but when I change vendorID in that table it affects the query and continues reading after the gap.
Its a very bizarre problem and its killing me, I've got some crazy queries going on that work no problem and in my mind this is the simplest query and it doesn't work.
Please help me.