I have the following code below that works fine, but I recently moved my tables to Azure and now it takes forever to complete. Can you guys see any obvious code optimizations that might help speed things up?
Code:
Private Sub Command4_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Inventory Base1"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Counter = 1
DoCmd.GoToRecord , , acLast
lastpart = Forms![Inventory Base1]![Part#]
Do
DoCmd.GoToRecord , , acGoTo, Counter
Currentpart = Forms![Inventory Base1]![Part#]
Forms![Inventory Base1]![Calculated Average Volume] = 0
Forms![Inventory Base1]![Future Inventory] = Forms![Inventory Base1]![Inventory-Current]
Forms![Inventory Base1]![Days of Inv] = 1000
Forms![Inventory Base1]![Days of Inv minus orders] = 1000
Counter = Counter + 1
Loop Until Currentpart = lastpart
DoCmd.OpenForm "Ave volume per month"
Counter = 1
DoCmd.GoToRecord , , acLast
lastpart = Forms![Ave Volume per month]![Part#]
Do
DoCmd.OpenForm "Ave volume per month"
DoCmd.GoToRecord , , acGoTo, Counter
Part1 = Forms![Ave Volume per month]![Part#]
Volume = Forms![Ave Volume per month]![Volumepermonth]
DoCmd.OpenForm "Inventory Base1"
Forms![Inventory Base1]![Part#].SetFocus
DoCmd.FindRecord Part1
Forms![Inventory Base1]![Calculated Average Volume] = Volume
Counter = Counter + 1
Loop Until Part1 = lastpart
DoCmd.OpenForm "Future Inventory"
Counter = 1
DoCmd.GoToRecord , , acLast
lastpart = Forms![Future Inventory]![Part#]
Do
DoCmd.OpenForm "Future Inventory"
DoCmd.GoToRecord , , acGoTo, Counter
Part1 = Forms![Future Inventory]![Part#]
Volume = Forms![Future Inventory]![Future Inv]
DoCmd.OpenForm "Inventory Base1"
Forms![Inventory Base1]![Part#].SetFocus
DoCmd.FindRecord Part1
Forms![Inventory Base1]![Future Inventory] = Volume
Counter = Counter + 1
Loop Until Part1 = lastpart
DoCmd.OpenForm "Inventory Base1"
Counter = 1
DoCmd.GoToRecord , , acLast
lastpart = Forms![Inventory Base1]![Part#]
Do
DoCmd.GoToRecord , , acGoTo, Counter
Currentpart = Forms![Inventory Base1]![Part#]
If Forms![Inventory Base1]![Calculated Average Volume] > 0 Then
Forms![Inventory Base1]![Days of Inv] = 30 * Forms![Inventory Base1]![Inventory-Current] / Forms![Inventory Base1]![Calculated Average Volume]
Forms![Inventory Base1]![Days of Inv minus orders] = 30 * Forms![Inventory Base1]![Future Inventory] / Forms![Inventory Base1]![Calculated Average Volume]
Else
End If
Counter = Counter + 1
Loop Until Currentpart = lastpart
DoCmd.Close acForm, "Inventory Base1"
DoCmd.Close acForm, "Future Inventory"
DoCmd.Close acForm, "Ave Volume per month"
stDocName = "tentative schedule"
DoCmd.OpenReport stDocName, acNormal
End Sub