Here is how far I have gotten:
Code:
Private Sub Command61_Click()
Dim DBSS As Database
Dim rs As DAO.Recordset
Dim rsrs As DAO.Recordset
Dim i As Integer
Dim j As Integer
Set DBSS = CurrentDb
If Me.txtTo & "" = "" Then
MsgBox "You Must Select a Location to Inventory", vbOKOnly + vbCritical, "Pick Location"
Else
For i = 1 To 20
If Me.Controls("item" & i) & "" = "" Or Me.Controls("n" & i) = 0 Then
Exit For
Else
Set rs = CurrentDb.OpenRecordset("SELECT DISTINCT Count(tblTransfers.TrackingID) AS CountOfTrackingID, tblTransfers.ProductName, tblProducts.PType, tblLocations.PLocation, tblTransfers.Used, tblProducts.ID " & _
"FROM (tblProducts INNER JOIN tblRequiredStock ON tblProducts.ID = tblRequiredStock.Product_FK) INNER JOIN (tblLocations INNER JOIN tblTransfers ON tblLocations.LocationID = tblTransfers.NewLocation) ON tblProducts.ID = tblTransfers.ProductName " & _
"GROUP BY tblTransfers.ProductName, tblProducts.PType, tblLocations.PLocation, tblTransfers.Used, tblProducts.ID, [type]=[type_fk] " & _
"HAVING (((tblTransfers.ProductName) = " & Me.Controls("item" & i).Column(0) & " ) And ((tblTransfers.Used) = True) And (([Type] = [type_fk]) = -1)) " & _
"ORDER BY tblLocations.PLocation;")
If rs.EOF Then
Set rsrs = CurrentDb.OpenRecordset("SELECT tblTransfers.TrackingID, tblTransfers.NewLocation, tblTransfers.ProductName, tblTransfers.Used FROM tblTransfers GROUP BY tblTransfers.TrackingID, tblTransfers.NewLocation, tblTransfers.ProductName, tblTransfers.Used HAVING (((tblTransfers.NewLocation)=" & Me.txtTo.Column(0) & " ) AND ((tblTransfers.ProductName)=" & Me.Controls("item" & i) & " ) AND ((tblTransfers.Used)=False));")
For j = 1 To Me.Controls("n" & i).Value
With rsrs
.Edit
!Used = True
.Update
End With
Next j
rsrs.Close
Set rsrs = Nothing
ElseIf Me.Controls("n" & i) > rs![CountOfTrackingID] Then
Set rsrs = CurrentDb.OpenRecordset("SELECT tblTransfers.TrackingID, tblTransfers.NewLocation, tblTransfers.ProductName, tblTransfers.Used FROM tblTransfers GROUP BY tblTransfers.TrackingID, tblTransfers.NewLocation, tblTransfers.ProductName, tblTransfers.Used HAVING (((tblTransfers.NewLocation)=" & Me.txtTo.Column(0) & " ) AND ((tblTransfers.ProductName)=" & Me.Controls("item" & i) & " ) AND ((tblTransfers.Used)=False));")
MsgBox "test worked"
End If
rs.Close
Set rs = Nothing
End If
Next i
End If
End Sub
But when i go to use it.. I get:
"Run-Time Error '3027': Cannot Update. Database or Object is read-only"
On debug it highlights .Edit
Thanks for the help