I am experiencing an issue when running a loop on my subform. The code works on the first record, but doesn't move to the second or additional records of the subform, if there is in fact additional records.
Below is my current code.
The code below was used to replace and test part of the above to see if the subform would return multiple records, that it will indeed call back each record.
Example if a record has 3 subform entries, 3 msgbox will display.
If a record has 1 subform entry, 1 msgbox will display.
Since the msgbox counts are appearing correctly, I am assumin the code is working but not sure why it will not change the values of the 2nd, 3rd, etc records, only the 1st.
PS. The message box always comes back blank, not returning the bag number. Not sure if thats an issue or not.
Below is my current code.
Code:
Private Sub Process_AfterUpdate()
Dim db As DAO.Database
Dim rst As DAO.Recordset
If Me![Process] = -1 Then
Me![Process Date] = date
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT * FROM tblPropertyDetails WHERE DetentionID=" & Key)
[COLOR=red]With db[/COLOR]
[COLOR=red]rst.MoveFirst[/COLOR]
[COLOR=red]Do While Not rst.EOF[/COLOR]
[COLOR=red]'check to see if bagnum has value first[/COLOR]
[COLOR=red]If IsNull(Forms![Detention Group Edit1]!SubfrmDetaineeReviewGroupOut.Form.BagNum) Then Exit Do[/COLOR]
[COLOR=red]Forms![Detention Group Edit1]!SubfrmDetaineeReviewGroupOut.Form.Combo268 = 2[/COLOR]
[COLOR=red]rst.MoveNext[/COLOR]
[COLOR=red]Loop[/COLOR]
[COLOR=black]End With[/COLOR]
[COLOR=black]rst.Close[/COLOR]
Set rst = Nothing
MsgBox "Update Information.", vbOKOnly, "Update when applicable"
Else: Me![Process Date] = ""
If Me![Process] = 0 Then
'check to see if bagnum has value first
If Not IsNull(Forms![Detention Group Edit1]!SubfrmDetaineeReviewGroupOut.Form.BagNum) Then
Forms![Detention Group Edit1]!SubfrmDetaineeReviewGroupOut.Form.Combo268 = 1
End If
End If
End If
End Sub
The code below was used to replace and test part of the above to see if the subform would return multiple records, that it will indeed call back each record.
Example if a record has 3 subform entries, 3 msgbox will display.
If a record has 1 subform entry, 1 msgbox will display.
Since the msgbox counts are appearing correctly, I am assumin the code is working but not sure why it will not change the values of the 2nd, 3rd, etc records, only the 1st.
PS. The message box always comes back blank, not returning the bag number. Not sure if thats an issue or not.
Code:
[FONT=Arial]With db[/FONT]
[FONT=Arial]Do While Not rst.EOF[/FONT]
[FONT=Arial]MsgBox BagNum[/FONT]
[FONT=Arial]rst.MoveNext[/FONT]
[FONT=Arial]Loop[/FONT]