Solved

MS Access Update Query How to Update All The Records On A Continuous Form Not Just The One I'm On

Posted on 2016-11-06
3
32 Views
Last Modified: 2016-11-06
I have a form that I am wanting to be able to update ALL the records on the form not just the one I am on.
How can I do this?

Thanks!

ProductID Combo Box 1:
SELECT Products.ProductID, [Skus].[Sku] & "" & [Conditions].[CondCode] AS [Product SKU]
FROM SKUs INNER JOIN (Conditions INNER JOIN Products ON Conditions.ConditionID = Products.ConditionID) ON SKUs.SkuID = Products.SkuID;

Open in new window



ProdLocLocID ComboBox 2:
SELECT ProdLocations.ProdLocID, ProdLocations.ProductID, Locations.LocNm
FROM Locations INNER JOIN ProdLocations ON Locations.LocID = ProdLocations.LocID
WHERE (((ProdLocations.ProductID)=[Forms]![frmStillBinded]![frmStockTransferbinded].[Form]![ProductID]));

Open in new window



Update Query Deduct Values From table ProdLocations
Where ProdLocLocID = [ProdLocations].[LocID]:
UPDATE (Products INNER JOIN ProdMovements ON Products.ProductID = ProdMovements.ProductID) 
INNER JOIN ProdLocations ON Products.ProductID = ProdLocations.ProductID SET ProdLocations.QtyLoc = [qtyloc]-[Forms]![frmStillBinded]![frmStockTransferbinded].[Form]![QtyMove]
WHERE (((ProdMovements.ProdLocLocID)=[Forms]![frmStillBinded]![frmStockTransferbinded].[Form]![ProdLocLocID]) AND ((ProdLocations.ProdLocID)=[Forms]![frmStillBinded]![frmStockTransferbinded].[Form]![ProdLocLocID]));

Open in new window

0
Comment
Question by:Dustin Stanley
  • 2
3 Comments
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 41876395
Forget queries and loop once through the RecordsetClone of the form and, for each record, perform the update - like you have been shown before.

Much easier, faster, and cleaner.

/gustav
0
 

Author Comment

by:Dustin Stanley
ID: 41876411
Thank you Gustav. I just logged back in to erase this question. I did like you showed me before.

Private Sub Command34_Click()

If Not (Recordset.EOF And Recordset.BOF) Then
    Recordset.MoveFirst 'Good habit
    Do Until Recordset.EOF = True

        'DoCmd.SetWarnings False
DoCmd.OpenQuery "qryStockTransferDeductFrom"
DoCmd.OpenQuery "qryStockTransferAddTo"
'DoCmd.SetWarnings True


        'Move to the next record. Don't ever forget to do this.
        Recordset.MoveNext
        
    Loop
Else
    MsgBox "There are no records in the recordset."
End If

MsgBox "Finished looping through records."

'Recordset.Close 'Close the recordset

End Sub

Open in new window


The only issue though I have now is my Addidtion "qryStockTransferAddTo". If I have two rows with the same [LocID] it will multiply the update by however many rows there are. Say I put qtymove 5 and have 3 rows with [LocID] 10 then it makes them all 15.

UPDATE Products INNER JOIN ((Locations INNER JOIN ProdLocations ON Locations.LocID = ProdLocations.LocID) INNER JOIN ProdMovements ON Locations.LocID = ProdMovements.LocID) ON (Products.ProductID = ProdLocations.ProductID) AND (Products.ProductID = ProdMovements.ProductID) SET ProdLocations.QtyLoc = [qtyloc]+[Forms]![frmStillBinded]![frmStockTransferbinded].[Form]![QtyMove]
WHERE (((ProdMovements.LocID)=[Forms]![frmStillBinded]![frmStockTransferbinded].[Form]![LocID]) AND ((Locations.LocID)=[Forms]![frmStillBinded]![frmStockTransferbinded].[Form]![LocID]));

Open in new window

0
 

Author Closing Comment

by:Dustin Stanley
ID: 41876472
Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now