I have a recipe making process built in Access. When you select an ingredient from the recipe it will, based on another selection (SKiD), run particular calculations and add the right amounts to the Master Batch Record that will be printed.
The problem, I set the number of inputs to I = 1 to To DLookup("[Num of Rows]", "qry_BP40_Gummy_We04_Pt4"). When I select Orange as my flavor, the code works correctly. When I choose Cherry for some reason, the code behaves incorrectly. It groups all individual numbers into 1 large number and adds that as a record. The code should divide the recipe quantity into equal partitions (as many as there are rows) and add the divided raw material and quantity as a record. My Next I says to run that same query again and again until the aforementioned DLookup.
At first I thought this was a MS Access glitch or one of those unexpected behaviors from Access, but this is ongoing and occurs whenever I select any flavor besides Orange.
Hopefully someone here will know what is going on. Or my worst fear may be true: this is just a weird glitch.
Please bear in mind, I'm a beginner at coding.
Code:
Private Sub We04_Pt1()
DoCmd.SetWarnings (WarningsOff)
DoCmd.OpenQuery "qry_BP40_Gummy_We04_Pt5"
DoCmd.OpenQuery "qry_BP40_Gummy_UPK_Add_Pt1"
DoCmd.SetWarnings (WarningsOn)
End Sub
Private Sub We04_Pt2()
Dim I As Integer
For I = 1 To DLookup("[Num of Rows]", "qry_BP40_Gummy_We04_Pt4")
DoCmd.SetWarnings (WarningsOff)
DoCmd.OpenQuery "qry_BP40_Gummy_We04_Pt6"
Next I
DoCmd.OpenQuery "qry_BP40_Gummy_UPK_Add_Pt2"
DoCmd.SetWarnings (WarningsOn)
DoCmd.RefreshRecord
End Sub
Private Sub Command522_Click()
Dim I As Integer
If DLookup("[Total]", "qry_BP40_Gummy_We04_Pt3") <= 30 Then
DoCmd.SetWarnings (WarningsOff)
DoCmd.OpenQuery "qry_BP40_Gummy_We04_Pt8"
DoCmd.OpenQuery "qry_BP40_Gummy_UPK_Add_Pt4"
DoCmd.SetWarnings (WarningsOn)
DoCmd.RefreshRecord
Else
If DLookup("[NumofRows2]", "qry_BP40_Gummy_We04_Pt4") <= 2 And Me.SKID <> "SKID5-F" Then
DoCmd.SetWarnings (WarningsOff)
DoCmd.OpenQuery "qry_BP40_Gummy_We04_Pt5"
DoCmd.OpenQuery "qry_BP40_Gummy_We04_Pt9"
DoCmd.OpenQuery "qry_BP40_Gummy_UPK_Add_Pt1"
DoCmd.OpenQuery "qry_BP40_Gummy_UPK_Add_Pt2"
DoCmd.SetWarnings (WarningsOn)
DoCmd.RefreshRecord
Else
Select Case Me.SKID
Case "SKID5"
Call We04_Pt1
Call We04_Pt2
Case "SKID5-F"
DoCmd.SetWarnings (WarningsOff)
DoCmd.OpenQuery "qry_BP40_Gummy_We04_Pt8"
DoCmd.SetWarnings (WarningsOn)
DoCmd.RefreshRecord
Case "SKID6"
For I = 1 To DLookup("[NumofRows]", "qry_BP40_Gummy_We04_Pt4")
DoCmd.SetWarnings (WarningsOff)
DoCmd.OpenQuery "qry_BP40_Gummy_We04_Pt7"
DoCmd.SetWarnings (WarningsOn)
DoCmd.RefreshRecord
Next I
Case "SKID7"
For I = 1 To DLookup("[NumofRows3]", "qry_BP40_Gummy_We04_Pt4")
DoCmd.SetWarnings (WarningsOff)
DoCmd.OpenQuery "qry_BP40_Gummy_We04_Pt10"
Next I
DoCmd.SetWarnings (WarningsOn)
DoCmd.RefreshRecord
End Select
End If
End If
End Sub