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
66 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 50

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

696 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