hello all! i am currently trying to create a code to look at my asset list form and upload selected records based on criteria. the issue is my loop continues to upload the same record over and over rather than moving though the records in the form. can you please help me? thank you so much.
as you can see each asset record has a rental number to check assets into. the first step is to ensure the IRQNumber is filled in prior to clicking the rented check box. this works great. the next step is to hit a form button to append each of the selected records. unfortunately my code as is only loops the first record rather than moving to the next checked record.
as you can see each asset record has a rental number to check assets into. the first step is to ensure the IRQNumber is filled in prior to clicking the rented check box. this works great. the next step is to hit a form button to append each of the selected records. unfortunately my code as is only loops the first record rather than moving to the next checked record.
Code:
Private Sub Rented_Click()
Dim IDvar As Integer
IDvar = Me.ID.Value
If IsNull(Me.IRQNumber) Then
Me.Rented.Value = 0
MsgBox " These records cannot be archived until IRQ number is entered"
Else
DoCmd.RefreshRecord
End If
End Sub
Private Sub Command271_Click()
Dim rst As Recordset, IDvar As Integer
Set rst = Me.RecordsetClone
IDvar = Me.ID.Value
rst.MoveFirst
Do While Not rst.EOF
If Me.Rented = True Then
DoCmd.RunSQL "Insert into TblAssetsOut (IRQNumber, ID, Rented)" & _
"Select AssetsExtended.IRQNumber, AssetsExtended.ID, AssetsExtended.Rented " & _
"from AssetsExtended where AssetsExtended.ID=" & IDvar
End If
Loop
rst.Close
MsgBox IDvar & " Transfer Complete"
Set rst = Nothing
End Sub
Last edited by a moderator: